rewrite condition problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux