httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Moravcik <smorav...@it-con.org>
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 example.com

This works and can be done with very simple rule:
     RewriteCond %{HTTP_HOST} !^www\.example\.com$
     RewriteRule ^/(.*) http://www.example.com/$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 
/free_trial[1-11]?

The rule should look like follow:
     RewriteCond %{HTTP_HOST} !^www\.example\.com$
     RewriteCond %{REQUEST_URI} !^/free_trial[1-9]?1?
     RewriteRule ^/(.*) http://www.example.com/$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,
Stefan

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message