httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Moravcik <>
Subject [users@httpd] rewrite condition problem
Date Tue, 10 May 2011 09:03:02 GMT
Hello list,

I want to do a rewrite rule for all URLs to get rewritten to

This works and can be done with very simple rule:
     RewriteCond %{HTTP_HOST} !^www\.example\.com$
     RewriteRule ^/(.*)$1 [R=301,L]

The problem is, when i want to exclude a URI.
So the scenario is to rewrite all TLDs to .com except those with 

The rule should look like follow:
     RewriteCond %{HTTP_HOST} !^www\.example\.com$
     RewriteCond %{REQUEST_URI} !^/free_trial[1-9]?1?
     RewriteRule ^/(.*)$1 [R=301,L]

For some reason this doesn't work. The regex is ok, when i delete "!" 
not char, everything works as expected. If the domain is not .com and 
the URI is free_trial to freetrial11, it will get rewritten, everything 
else is not. So i used the ! to get the revert result, everything get 
rewritten except free_trial to free_trial11. But with ! in place, 
everything including free_trials pages will get rewritten. It looks like 
REQUEST_URI with ! is ignored completely. Any suggestion how i could 
make this work or any idea, why my rewrite condition doesn't work.

Best Regards,

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message