I have a long standing problem with mod_rewrite and 1and1 shared hosting (hope that being shared hosting does't get this migrated to 'sharedserverfault'). Everything about the rewrite rules work fine - except when 'index' is in the path. Then I get an Apache 404 error.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]
Pretty standard so far, works fine on most server. On 1and1's server I get a 404 error if index is the top 'directory'. Anything starting with 'http://example.com/index' will give a 404.
- http://example.com/index
- http://example.com/index/action
- http://example.com/index/what/ever.anything
If I copy index.php to bootstrap.php and change the .htaccess file to point there and delete index.php, it will work.
However, that makes it a pain to update the server - any ideas what apache settings are causing this? Obviously I can't change the main configuration file, but I can override settings with the .htaccess file.
Found the answer here:
So the solution is to add:
to the .htaccess file.
If you name a file
index
and put it in your root, does it 404, or load that file? I would try overriding theDirectoryIndex
directive in your.htaccess file. The default there is usually index.html, but maybe yours is just index.