Exclude path from RewriteRule using RewriteCond in Apache2

by Madoc Comadrin   Last Updated June 13, 2019 10:00 AM

I have Apache server version 2.4.18 (Ubuntu).

I have conditional RewriteRule that applies to most parts of my site. I want to exclude paths starting with /norewrite from that rewrite.

The rewrite looks like this:

RewriteCond <condition 1>
RewriteCond <condition 2>
RewriteRule ^.*$ https://example.com [L]

I tried to exclude /norewrite with following:

RewriteCond <condition 1>
RewriteCond <condition 2>
RewriteCond %{REQUEST_URI} !^/norewrite
RewriteRule ^.*$ https://example.com [L]

I have also tried different syntaxes such as !/norewrite, !norewrite and !^\/norewrite but with all these the addresses starting with /norewrite still get rewriten when the 2 other conditions are true.

After reading Apache docs for RewriteCond and RewriteRule I belive that this should work. What am I doing wrong here?



Related Questions


Updated June 20, 2018 14:00 PM

Updated April 17, 2015 21:00 PM

Updated June 18, 2019 09:00 AM

Updated April 17, 2015 22:00 PM

Updated September 21, 2015 20:00 PM