Re: mod_rewrite - rewrite url AND domain - how to!?

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

 





On 05/09/11 07:18 AM, Tommy Ipsen wrote:
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


Best just create two vhosts, and use Redirect / http://www.newdomain.dk/ in the www.domain1.dk vhost. Repeat for each redirection.

Note that rewriting to a fully qualified URL will trigger an external redirect, anyway.

Frank

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