seeker_of_bacon seeker_of_bacon - 3 months ago 12
Apache Configuration Question

.htaccess redirects /robots.txt to /robots.txt/

Currently I have the following in

.htaccess
file:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)([^/])$ /$1$2/ [R=302,L]


This line
RewriteCond %{REQUEST_FILENAME} !-f
does not exclude txt files. How can I also exclude txt files from the following
RewriteRule
?

Answer

You can exclude .txt files using the following condition

RewriteCond %{REQUEST_URI} !\.txt$