Search code examples
codeignitercodeigniter-2

CodeIgniter: urlencoded URL in URI segment does not work


I'm trying to put a URL as the value of one of my URI segments in CI. My controller method is defined to accept such an argument. However, when I go to the URL, I get a 404 error. For example:

www.domain.com/foo/urlencoded-url/

Any ideas what's wrong? Should I do this via GET instead?

UPDATE:

// URL that generates 404 http://localhost/myapp/profile_manager/confirm_profile_parent_delete/ugpp_533333338/http%3A%2F%2Flocalhost%2Fmyapp%2Fdashboard%2F

// This is in my profile_manager controller public function confirm_profile_parent_delete($encrypted_user_group_profile_parent_id = '', $url_current = '')

If I remove the second URI segement, I don't get a 404: http://localhost/myapp/profile_manager/confirm_profile_parent_delete/ugpp_533333338/


Solution

  • It seems that the %2F breaks things for apache.

    Possible solutions:

    1. preg_replace the /'s to -'s (or something else) before sending the url then switch it back on the other end.
    2. Set apache to AllowEncodedSlashes On
    3. bit of a hack, but you could even save the url to a session variable or something instead of sending through the url *shrug *
    4. double url encode it before sending