1

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 !

Sylvain V
  • 21
  • 1
  • 2
  • 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
  • In the future, this might be of use: http://www.latenightpc.com/blog/archives/2007/09/05/a-couple-ways-to-debug-mod_rewrite – mbrownnyc Jul 25 '11 at 11:09

1 Answers1

2

Convert comment to CW

I got it working with

RewriteEngine On
RewriteCond %{REQUEST_URI} !^(.*)/dir1(.*)$
RewriteCond %{REQUEST_URI} !^(.*)/dir2(.*)$
RewriteRule (.*) - [R=404,L]
masegaloeh
  • 17,978
  • 9
  • 56
  • 104