Jump to content

Archived

This topic is now archived and is closed to further replies.

TFT2012

Codeigniter, 404 page not found

Recommended Posts

I have setup the CI app at the port 9001. I didn't do the rewrite things. So my url looks like the original one mysite:9001/index.php/category/shoes. It works well before I setup the Squid.

I tried to setup the Squid on the same server with Apache. I assigned the port 9000 to Squid.

To test, I added a simple sysinfo.php file to display phpinfo on the root of my app.

 

It works if I do mysite:9000/sysinfo.php (go through Squid).

However if I do mysite:9000/index.php/category/shoes, it will say "404 page not found". The mysite:9001/index.php/category/shoes still works though.

 

Can anyone give me a hand on this? Thanks!

Share this post


Link to post
Share on other sites

Figured it out.

 

Since the CI will get $uri = $_SERVER['REQUEST_URI'] at the begining even doing the setup $config['uri_protocol'] = 'AUTO'; in config.php.

Using the link through Squid, the $uri will return full http path, like http://mysite:9000/... However, using the link without passing Squid will just return "/index.php/....". The later is recoginzed by CI correctly, but the 1st is not.

So I go to system/core/URI.php, add the following to take of the "http://" part, just make its format same as "/index.php/...."

private function _detect_uri()
	{
		if ( ! isset($_SERVER['REQUEST_URI']) OR ! isset($_SERVER['SCRIPT_NAME']))
		{
			return '';
		}

		$uri = $_SERVER['REQUEST_URI'];
                // Starts here
		if(strstr($uri, 'http'))
		{
			$temp_uri = explode(':', $uri);
			$uri 	  = str_replace($_SERVER['SERVER_PORT'], '', $temp_uri[2]);
		}
		// Ends here
		if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0)
		{
			$uri = substr($uri, strlen($_SERVER['SCRIPT_NAME']));
		}

................
................
}

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.