I need to add an exception for a specific file in my .htaccess. I've tried to add this line: RewriteRule ^/print.php$ - [L], but it has no effect. Can anybody figure out why?

The whole file looks like this:

RewriteEngine on
RewriteBase /
RewriteRule !^pub - [C]
RewriteRule !^design - [C]
RewriteRule !^bilder - [C]
RewriteRule !^filer - [C]
RewriteRule !^js - [C]
RewriteRule !^pub2010 - [C]
RewriteRule ^/print.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /index.php [L,QSA]
link|improve this question
feedback

1 Answer

In a .htaccess file, the input to be matched against the pattern doesn't start with a slash.

Try this instead:

RewriteRule ^print.php$ - [L]

Incidentally, you can shorten all of those chained rules into just one:

RewriteRule !(^pub|^design|^bilder|^filer|^js|^pub2010) - [L]
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.