Welcome Guest, Not a member yet? Register   Sign In
CI running on CGI problem (when using uri_protocol = AUTO) + solution
#1

[eluser]kipras[/eluser]
Hi,

i had a problem after i uploaded a project to a server, that runs PHP through CGI.
After a bit of searching in the forums the only solutions i found involved editing config.php, but i did not want to do that.

So after a bit of hacking i found a quick solution - when figuring out urls CI uses $_SERVER['SCRIPT_NAME'] variable, but on that server $_SERVER['SCRIPT_NAME'] held the same value as $_SERVER['REQUEST_URI'], whereas the actual SCRIPT_NAME was moved to $_SERVER['ORIG_SCRIPT_NAME']. I added an additional check and it worked.
It seems to be a clean way to solve this, so i suggest including this in CI. I'm actually curious, has nobody had the same problem yet?

I attached a patch to this post. It modifies system/core/Config.php and system/core/URI.php
The patch is written against CI 2.0.0, but i checked 2.0.2 (the latest at the time of writing) and it should be straightforward to do the same changes to it too.

This patch fixes this problem, when using $config['uri_protocol'] = 'AUTO' (which is the default, and supposed to work in most situations).
I tried other settings later, and 'REQUEST_URI' also worked on the CGI server, but i think its probably better if 'AUTO' works too, right?
#2

[eluser]n0xie[/eluser]
What .htaccess are you using? Does it include a '?' ? If so does your site 'break' when adding ?glcid=1 to any url?
#3

[eluser]kipras[/eluser]
I currently have limited access to the server which is running the site (as in, i don't have access to it the entire time, because there are ridiculous security checks in place).

But the next time i will connect to it, i will check for the ?glcid=1 thing

Here are the contents of the .htaccess that is used:

RewriteEngine on

# If not file and directory
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d

RewriteCond $1 !^(index\.php|images|DOCS|styles|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]


UPDATE:

The ?glcid=1 thing at the end of the URL does not make any difference - it still does infinite redirection without the patch, and works fine with the patch.




Theme © iAndrew 2016 - Forum software by © MyBB