Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter with php5 - CI-generated 404 Error

[eluser]Eric Cope[/eluser]
Hello all,
I am developing an admin page for a client using CodeIgniter. I started developing in php4. However, now the server supports php5 only under the following conditions:

1. all php files have extension .php5
2. .htaccess be edited to include "AddType application/x-httpd-php5 .php5 .php"

I chose the second option. Now, I get a codeIgniter-generated 404 error for root page.
Any ideas?

If I remove that line in my .htaccess page, it functions properly again.

[eluser]Eric Cope[/eluser]
I have tracked it down to the Router.php file, the _validate_segments function. I will post more information as I find it.

[eluser]Eric Cope[/eluser]
I found the reason why this fails...
In the function, _set_route_mapping(), on line 94(ish):
$this->uri_string = $this->_get_uri_string();
with .htaccess empty, this returns "".
when I add that line to .htaccess, $this->uri_string returns "admin/index.php".

The following line of CI code is:
if ($this->uri_string == '')
the existance of /admin/index.php forces additional processing where when it is '', the default controller is selected and everything is dandy.

not sure why it is coming through for php5 and not php4...
The saga continues...

[eluser]Eric Cope[/eluser]
I have noticed that only I am participating in this conversation, which means I am talking to myself (including this message). <in muttering tone> fantastic...

[eluser]Eric Cope[/eluser]
I have pin pointed the exact point where the two different version diverge.
In Router.php;
function _get_uri_string()
        if (strtoupper($this->config->item('uri_protocol')) == 'AUTO')

            // If the URL has a question mark then it's simplest to just
            // build the URI string from the zero index of the $_GET array.
            // This avoids having to deal with $_SERVER variables, which
            // can be unreliable in some environments
            if (is_array($_GET) AND count($_GET) == 1)
                // Note: Due to a bug in current() that affects some versions
                // of PHP we can not pass function call directly into it
                $keys = array_keys($_GET);
                return current($keys);
            // Is there a PATH_INFO variable?
            // Note: some servers seem to have trouble with getenv() so we'll test it two ways        
            $path = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');        
            if ($path != '' AND $path != "/".SELF)
                return $path;
            // No PATH_INFO?... What about QUERY_STRING?
            $path =  (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING');    
            if ($path != '')
                return $path;
            // No QUERY_STRING?... Maybe the ORIG_PATH_INFO variable exists?
            $path = (isset($_SERVER['ORIG_PATH_INFO'])) ? $_SERVER['ORIG_PATH_INFO'] : @getenv('ORIG_PATH_INFO');      
            if ($path != '' AND $path != "/".SELF)
                return $path;

            // We've exhausted all our options...
            return '';
You may see $_SERVER['ORIG_PATH_INFO']. This does not exist for the php4 scenario. Additionally, @getenv('ORIG_PATH_INFO') returns false.
However, when that line is inserted into the .htaccess file, it does exist and matches the getenv and is 'admin/index.php'. It looks like it compares itself against SELF. However, SELF is only the file name, not a partial path, like what I am dealing with...
This path is returned and all hell is broken loose.
stay tuned...

[eluser]Eric Cope[/eluser]
I should note that this is using CI 1.5.4.

I hope you don't mind me joining your debate. Wink

Anyway have you tried poking around with the uri_protocol config item?

| 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
| 'REQUEST_URI'        Uses the REQUEST_URI
$config['uri_protocol']    = "AUTO";

[eluser]Derek Jones[/eluser]
Who is your host, Eric? I'm investing a similar issue where ORIG_PATH_INFO does not contain the correct value when no URI information is included along with the script.

[eluser]Eric Cope[/eluser]
I have not tried tinkering with the uri_protocol. I prefer to leave it as AUTO. I am interested in knowing where the ORIG_PATH INFO constant is generated...

[eluser]Eric Cope[/eluser]
[quote author="Derek Jones" date="1202068789"]Who is your host, Eric? I'm investing a similar issue where ORIG_PATH_INFO does not contain the correct value when no URI information is included along with the script.[/quote]
I resell through Cirtex.
That is like my problem, except it is not the entire path, just relative to the web root.

Theme © iAndrew 2016 - Forum software by © MyBB