TFT2012 Posted September 20, 2013 Share Posted September 20, 2013 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! Link to comment https://forums.phpfreaks.com/topic/282314-codeigniter-404-page-not-found/ Share on other sites More sharing options...
TFT2012 Posted September 20, 2013 Author Share Posted September 20, 2013 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'])); } ................ ................ } Link to comment https://forums.phpfreaks.com/topic/282314-codeigniter-404-page-not-found/#findComment-1450484 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.