Welcome Guest, Not a member yet? Register   Sign In
url redirect

how to do these effect in codeigniter :
To visit url: /a/b , but must login in correctly. if not, redirect to /login/index . then logining, if correctly login. redirect to url /a/b again.
I tried many times, use rawurlencode() to let /a/b as part of request url , but show not found page. would you please give me one idea? thanks.

There a number of techniques you could use:

1. Store previous page using get or post
2. using session to store previous page
3. using $_SERVER['HTTP_REFERER'] to get the previous page

Check out a solution here

thanks your reply. Ye , i get the idea. but about 1 and 3 point . i can not understand clearly. My question's key is how to redirect back to the page before logining, it's url is Dynamic. such as domain/a/b or domain/b/c/d ...
i can not transfer the url of before page as a request querystring . even though using rawurlencode():
$preurl = $this->uri->uri_string();
             header("location:HTTP://".$_SERVER["HTTP_HOST"]."/login/index/".rawurlencode($preurl ));
ie prompt: 404 error no such page. why?
after check, location is such as: HTTP://".$_SERVER["HTTP_HOST"]."/login/index/a/b
why rawurlencode() no effect??

Theme © iAndrew 2016 - Forum software by © MyBB