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

I'm trying to configure Apache to return a default 404 page when the / of DocumentRoot is called, except for some directories in that DocumentRoot

Unfortunately, I'm getting a 404 even for the directories that have been specified in the RewriteCond directive.

Here is my setup :

RewriteEngine On
RewriteCond ${REQUEST_URI} !/dir1/
RewriteCond ${REQUEST_URI} !/dir2/
RewriteRule (.*) - [R=404,L]

Thanks for your help !

share|improve this question
nm, got it working with RewriteEngine On RewriteCond %{REQUEST_URI} !^(.*)/dir1(.*)$ RewriteCond %{REQUEST_URI} !^(.*)/dir2(.*)$ RewriteRule (.*) - [R=404,L] –  Sylvain V Jul 25 '11 at 11:09

1 Answer 1

Your Answer


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.