简体   繁体   中英

PHP Redirect without encoding URL

I have a codeigniter app that has an authentication system. Sometimes a user will get logged out and they will get forwarded to site.com/login?redir=feature/9+1/abc . Upon logging in they should get forwarded to site.com/feature/9+1/abc

The problem arises when the user is forwarded: the + in the URL is changed to %20 . % is a disallowed URL character so my users sees an error message saying an invalid character is in the URL. Even if I add % to the list of allowed characters site.com/feature/9%201/abc is not the same as site.com/feature/9+1/abc and the user sees a 404 error.

Is there there a way I can forward users using PHP to /feature/9+1/abc instead of /feature/9%201/abc ?

Modify login url to site.com/login?redir=feature/9%2B1/abc . That should do the trick.

it may be useful for you as it worked for me

try urlencode function http://php.net/manual/en/function.urlencode.php in the time of sending and to fetch use urldecode function

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM