Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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]
share|improve this question
add comment

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]
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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