• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to keep $this->uri->segment from stripping out + (plus) char

#1
[eluser]lukeinjax[/eluser]
I have a page where I'm trying to include a plus in the url. I've allowed the plus char in my config file in 'permitted_uri_chars', but for some reason $this->uri->segment seems to be stripping out the + chars and replacing them with _. Can anyone tell me how to get around this?

If I do:
echo $_SERVER['REQUEST_URI'];

I get:
/search/plumber/jacksonville_fl_+_tx

If I do:
echo $this->uri->segment(3);

I get:
jacksonville_fl___tx

#2
[eluser]madeks[/eluser]
Not sure can this be done by add the "+" to this var, permitted_uri_chars in the config file?

#3
[eluser]TheFuzzy0ne[/eluser]
That's a strange issue. I'd suggest that you copy ./system/libraries/URI.php to ./system/application/libraries/URI.php, and then you can edit that file and debug it accordingly. I think that the problem may be caused by the _parse_request_uri() method.

#4
[eluser]Colin Williams[/eluser]
Your server (maybe PHP itself) is doing this, not CI. Best solution is to set uri_protocol in config.php to REQUEST_URI and not PATH_INFO, because, well, as you already pointed out, your server will leave +s alone in the REQUEST_URI variable.

Compare with this code:

Code:
echo $_SERVER[‘REQUEST_URI’];
echo $_SERVER[‘PATH_INFO’];

You'll see that PATH_INFO has been modified. Again, not sure if this is happening because of Apache or PHP. I've never really found a setting that turns it off.

#5
[eluser]lukeinjax[/eluser]
[quote author="Colin Williams" date="1247603433"]Your server (maybe PHP itself) is doing this, not CI. Best solution is to set uri_protocol in config.php to REQUEST_URI and not PATH_INFO, because, well, as you already pointed out, your server will leave +s alone in the REQUEST_URI variable.

Compare with this code:

Code:
echo $_SERVER[‘REQUEST_URI’];
echo $_SERVER[‘PATH_INFO’];

You'll see that PATH_INFO has been modified. Again, not sure if this is happening because of Apache or PHP. I've never really found a setting that turns it off.[/quote]

Changing the $config['uri_protocol'] to "REQUEST_URI" fixed it. Thanks Colin!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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