Forum Moderators: phranque
It seems like if the file exists, the file will be loaded, otherwise it's redirected to index.php. I want apache to automatiaclly send 404-error for example someone requests /testfile.xml and it does not exist.
Is this some sort of setting in Apache or why does it do this? Maybe I have missed something simple, I don't know.
The htaccess-file looks like this:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^domain\.com [NC]
RewriteCond %{REQUEST_URI} !.*images/.* [NC]
RewriteCond %{REQUEST_URI} !.*adminsection/.* [NC]
RewriteCond %{REQUEST_URI} !.*en/.* [NC]
RewriteCond %{REQUEST_URI} !.*\.htm$ [NC]
RewriteCond %{REQUEST_URI} !.*\.css$ [NC]
RewriteCond %{REQUEST_URI} !.*\.xml$ [NC]
RewriteCond %{REQUEST_URI} !.*\.php.* [NC]
RewriteCond %{REQUEST_URI} !.*\.txt$ [NC]
RewriteRule ^(.*)$ index.php [L]
Options +FollowSymLinks -MultiViews
Also, you may delete ".*" anywhere it occurs at the start of a pattern and is not preceded by "^", and anywhere it occurs at the end of a pattern and is not followed by "$". In these two cases, ".*" is a waste of characters and CPU time, as it does not change the pattern's behaviour. Example: Your "!.*images/.* [NC]" pattern can equally-well be written as "!images/ [NC]"
If you mean to specify that something must precede or follow the path, then use ".+", not ".*"
Jim
Your suggestions of -MultiViews does not help I'm afraid.
Thanks for the other tip. I know regular expressions but not so much about htaccess and Apache.
Edit: if I remove the .htaccess file I get 404 Error Not Found when trying to access /file.xml.
[edited by: FredrikMH at 3:45 am (utc) on June 4, 2008]
It works like it should now and I have no idea why this happend, since I created this account just a day ago as well. Something must have gone wrong.