Linux – .htaccess rewrite: How to add exception for specific files

.htaccessapache-2.2linux

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]

Best 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]
Related Topic