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?


Messages In This Thread
CI running on CGI problem (when using uri_protocol = AUTO) + solution - by El Forum - 04-13-2011, 06:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB