Jump to content

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!

Edited by TFT2012
Link to comment
https://forums.phpfreaks.com/topic/282314-codeigniter-404-page-not-found/
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']));
		}

................
................
}
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.