• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
url redirect

#1
[eluser]Unknown[/eluser]
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.

#2
[eluser]Otemu[/eluser]
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

#3
[eluser]Unknown[/eluser]
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():
Code:
$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??


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.