httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Frank Gingras <francois.ging...@gmail.com>
Subject Re: [users@httpd] mod_rewrite - rewrite url AND domain - how to!?
Date Mon, 05 Sep 2011 14:02:24 GMT


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

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