Take the 2-minute tour ×

I'm trying to set up a simple rule in my httpd.conf as a precursor to some more complex rules I need to set up.

If I use this:

RewriteCond %{REQUEST_URI} ^/test\.txt
RewriteRule ^(.*)$ [R,L]

... then a request for /test.txt goes to port 8080, as expected.

But if I add a ! to flip the REQUEST_URI match, like this:

RewriteCond %{REQUEST_URI} !^/test\.txt
RewriteRule ^(.*)$ [R,L]

... then every request gets sent to port 8080, including requests for /test.txt. I was expecting text.txt to be allowed through because the RewriteCond would be applying the following rule to every request that doesn't match /text.txt.

What stupid, simple mistake am I making here? I Googled until I got dizzy.

share|improve this question
It's probably related to your other rules (for reasons I can elaborate on), could you post them as well? –  Tim Stone Sep 2 '10 at 14:28
Thanks, Tim - there are no other rewrite rules beyond the standard TRACE/TRACK blocker. However, I've set up a fresh Apache install on a spare machine and the rules above are working there as I'd expect, so it's obviously something to do with the setup on the first machine. This isn't so bad because I just wanted a machine to build the rules on, and I can do that with the new install. –  Nick Sep 2 '10 at 16:28

1 Answer 1

This problem appears to be a result of other configuration settings on the machine in question, as the rules are working fine on a vanilla Apache install.

share|improve this answer

Your Answer


