Reputation: 628
I have a codeigniter project installed in /var/www/html. URLs should look like this: http://example.com/clients/abc I am running CentOS and Apache 2.2.15
In order to get the routes to work properly I have enabled mod_rewrite (which I can see is on through phpinfo.php) and AllowOverride All in httpd.conf.
My documentroot defined in httpd.conf is /var/www/html.
The .htaccess file in /var/www/html is:
<IfModule mod_rewrite.c>
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
</IfModule>
Just this by itself I get 404 pages on all my controllers and none of my contollers/views render other than index.
However. If I create a second .htaccess file in /var/www and put this one line in it:
ErrorDocument 404 /index.php
Now my rewrite works and my controllers and all my pages load properly. However I still get a 404 page not found in firebug yet my pages still load.
There is some kind of weird and crazy thing happening here that I do not understand or respect. Double redirects? Apache doesn't know what DocumentRoot means? Why is the /var/www/html/.htaccess file not being recognized unless I have another .htaccess file in /var/www?
Upvotes: 1
Views: 1652
Reputation: 628
Found the problem.
In httpd.conf I changed
<Directory "/var/www/html">
AllowOverride none
to
<Directory "/var/www/html">
AllowOverride All
This was difficult to spot because there were a significant amount of comments within that Directory setting and it obscured it. There were numerous other AllowOverride All statements in the .conf file too which made me think I had the setting set already.
Also I learned from a guy named 'thumbs' on IRC that I should just place the contents of my .htaccess file right into the <Directory> settings in httpd.conf. When you do that you can change back to AllowOverride none and get a significant performance boost.
Upvotes: 3