0

MY CodeIgnitor setup returns 404 on any URL expect the base url http://x.example.com/test/). When I try to visit an URL such as http://x.example.com/test/foobar/177 , I get the following 404:

Not Found

The requested URL /index.php/foobar/177 was not found on this server.

When I check my web server log (this is Webfaction) it just says:

[Mon Mar 19 12:23:45 2012] [error] [client 12.34.56.78] File does not exist: /var/www/html/no_app_on_root.htmlindex.php

The way that a file path has been concatenated with index.php is odd, no?

Here's my .htaccess:

Options +FollowSymLinks

# Set which file that's fetched if only directory is specified
DirectoryIndex index.php index.html index.htm

# don't list category structures
Options -Indexes

# don't display .htaccess files
<Files .htaccess>
order allow,deny
deny from all
</Files>


<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#‘system’ can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn’t true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css folders, and the robots.txt file
#Submitted by Michael Radlmaier (mradlmaier)
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>


<IfModule !mod_rewrite.c>
# If we don’t have mod_rewrite installed, all 404’s
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin

ErrorDocument 404 /index.php
</IfModule>

My routes.php:

$route['default_controller'] = "home";
$route['404_override'] = '';

$route['foobar/177'] = "foobar/foobar_177";
$route['foobar/:num/add'] = "foobar/add";
$route['foobar/:num/review'] = "foobar/review";
$route['foobar/:num'] = "foobar";

my config.php (yes, the site is in a directory on a sub domain):

$config['base_url'] = 'http://x.example.com/test/';

$config['index_page'] = '';

$config['uri_protocol'] = 'AUTO';
1

2 Answers 2

0

Your rewrite rule that is used to hide index.php from the url

RewriteRule ^(.*)$ /index.php/$1 [L]

Sends all requests to /index.php/$1

And there aren't handlers for those, you need to specifically tell Apache that you don't want some URLs being redirected to index.php

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry but I don't understand you.
0

In the file: config.php

Edit this line:

$config['uri_protocol'] = 'AUTO';

to:

$config['uri_protocol'] = 'QUERY_STRING';

And your .htaccess file should look like:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

4 Comments

I have moved the system and application folders from the docroot, does that change anything?
I went ahead and tried you two changes. I still get 404 but at least the index.php isn't inserted in the urls: The requested URL /test/foobar/177 was not found on this server.
This means that .htaccess file is not found in ROOT or code inside it doesn't run. make sure about it.
I've verified that .htaccess is processed by apache.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.