Search code examples
phpcodeigniterurlencodeurl-encodingurldecode

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?


Solution

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