Welcome Guest, Not a member yet? Register   Sign In
spaces in URLs converted to _
#31

[eluser]sophistry[/eluser]
my suggestion is to create a directory with spaces or plus signs in it (if the OS you run will let you). my contention is that the ISP is changing anything that looks like a space character into an underscore BUT, only when it appears in something that looks like a path (like a CI "segment"). that would explain why you can pass spaces as part of a GET parameter (ie, the part of the URI after the ?).

but, since you recently changed hosting it wouldn't make sense that two providers do the same thing unless they are using the same backend setup.

in any case def. ask them whether they muck with the URIs before you get them.

so, it's open source, why not just follow the code execution and put in exit() at one point at a time and see what the uri var looks like all along the way.

just start at index.php and you'll see what CI loads - it's pretty straightforward. you might start by printing the $_SERVER var right in index.php and see what is there. if any of the URI vars have been modified to underscores in index.php (before the CI include at the bottom) then you know it is the hosting provider or even your own .htaccess file doing the transformation.

let us know.
#32

[eluser]AtlantixMedia[/eluser]
I tracked the $_SERVER vars down to the actual controller function and these are my findings:

1) by inserting a

Code:
die('<b>This is the complete URL:</b> http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . '<br /><b>This is the controller function parameter:</b>' . $query);

at the very beginning of the controller function I get this:

This is the complete URL: http://www.mydomain.com/search/main/hand...h/damn+hot
This is the controller function parameter:damn_hot

2) so it looks like the pluses are still in the $_SERVER but NOT in the parameter as passed to the method....any thoughts?
#33

[eluser]sophistry[/eluser]
now, put that line in the index.php file and follow the code execution. obviously, you won't have the $query variable in the index.php, but eventually in your code following and debugging, you'll come to a place where the URI starts to be reconstructed and you will have your answer.

keep going, getting there.
#34

[eluser]AtlantixMedia[/eluser]
to be honest, I'm kind of lost. I went as far as CI_URI::_fetch_uri_string() and found out that they uri is wrapped inside $_GET and + are already replaced with _. wasn't $_GET disallowed by CI?

Also, when I go to http://www.mydomain/search/main/handlese...ne+you+are I get a "The URI you submitted has disallowed characters." error even though I have

Code:
$config['permitted_uri_chars'] = "+a-z 0-9~%.:_'-";

in my config file?

I'm probably not approaching this the right way. What I need to accomplish is a "google style" search system. the above query would like like this in google

http://www.google.com/search?hl=en&safe=...tnG=Search

can I even do this with CI??

thanks

thanks
#35

[eluser]sophistry[/eluser]
just a quick hint... if you want to have a single-quote in the permitted chars you have to escape it:

Code:
$config['permitted_uri_chars'] = "\'+a-z 0-9~%.:_\-";
#36

[eluser]sophistry[/eluser]
poking around in the config.php file led me to this... does it help to change this setting?
Code:
/*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| This item determines which server global should be used to retrieve the
| URI string.  The default setting of "AUTO" works for most servers.
| If your links do not seem to work, try one of the other delicious flavors:
|
| 'AUTO'            Default - auto detects
| 'PATH_INFO'        Uses the PATH_INFO
| 'QUERY_STRING'    Uses the QUERY_STRING
| 'REQUEST_URI'        Uses the REQUEST_URI
| 'ORIG_PATH_INFO'    Uses the ORIG_PATH_INFO
|
*/
$config['uri_protocol']    = "AUTO";
#37

[eluser]Sixer[/eluser]
I have the exact same problem. Anything in $this->uri->segment_array() gets underscores instead of spaces. Is there a fix for this yet?

It is most definitely CI related as the project I'm working on didn't do this before I put it into CI.

$config['permitted_uri_chars'] settings make no difference.
#38

[eluser]cyang[/eluser]
Aloha all. Just ran into the same problem, and I think the issue is dependent on your web server and the URI protocol setting that sophistry mentioned. Running Apache 2.2.6 with default config and URI protocol set to 'AUTO', all my spaces belonged to underscore. Setting URI protocol to 'QUERY_STRING', though, gave them back to me. I'd suggest trying a bunch of different URI protocol settings and seeing if any of them solve the problem (as an aside, I recall having to change the setting to even get the default welcome controller to load when I switched hosts once).

Also, reminder that you'll have to adjust the permitted uri characters to allow '+', else you'll get the disallowed characters error.

Hope that helps!
#39

[eluser]sophistry[/eluser]
@cyang...

thanks for the update on this info. i figured out that this is due to the way that PHP handles variables (or at least used to handle them with register_globals=on). in the olden days of PHP incoming GET and POST variables were automatically assigned to variables in the global namespace. this caused much ruination in the world of PHP and consequently PHP gods changed register_globals=off so this didn't happen.

however, when the dust cleared some of the vestigal variable "managing" remained. specifically, dots and spaces were changed to underscores by PHP if it thought the developer might use the incoming GET or POST data as a variable.

This version of this PHP bug has a nice round number: 40000!
http://bugs.php.net/bug.php?id=40000

your suggestion to try a bunch of different settings to see what works is good.

cheers.
#40

[eluser]maesk[/eluser]
I just ran into the same issue as well, after a lot of print_r()'s and playing with the permitted URI chars etc. I thought let's try the forum and thankfully I found this thread. Special thanks to sophistry and cyang for pointing this out because it would have taken me hours to find this if at all...

Code:
$config['uri_protocol']    = 'REQUEST_URI';

(config.php, around line 46) did the trick for me.




Theme © iAndrew 2016 - Forum software by © MyBB