mod_rewrite - rewrite url AND domain - how to!?

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

 



Hi group

I have a need to rewrite domains and urls based on specific rules but I can't figure out the "correct" way to do it using mod_rewrite.

What I have and what I want:
http://www.domain1.dk/		> http://www.newdomain.dk/
http://www.domain2.dk/		> http://www.newdomain.dk/
http://www.domain3.dk/		> http://www.newdomain.dk/
http://www.domain1.dk/Something	> http://old.domain1.dk/Something
http://www.domain2.dk/Something	> http://old.domain2.dk/Something
http://www.domain3.dk/Something	> http://old.domain3.dk/Something

My initial idea was something like this:

RewriteRule ^http\://www\.(domain1|domain2|domain3)\.dk/$ http://www.newdomain.dk/ RewriteRule ^http\://www\.(domain1|domain2|domain3)\.dk/(.+)$ http://old.$1.dk/$2

But now I understand that RewriteRule works with the URL part of the complete request so I can't match the domain part with RewriteRule!?

Does this mean I need to use RewriteCond %{HTTP_HOST} and create two rewrite rules for each of the above domains?

What is the smartest, fastest and most elegant way to solve this problem?

Cheers, Tommy Ipsen


---------------------------------------------------------------------
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