httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin Pasher <just...@newmediagateway.com>
Subject Re: [users@httpd] Rewrite: modify http_host for many subdomains
Date Wed, 20 May 2009 20:43:00 GMT
Pete Nesbitt wrote:
> Hi,
> We are changing one of our domain names which has about 150 host/subdomains. 
> Apache version is 2.0.52 on RHEL4
>
> Current http_host's would look something like this:
> service1.old-domain.com
> service2.old-domain.com
> host1.subdom1.old-domain.com
> etc...
>
> I need to make them read:
> service1.new-domain.com
> service2.new-domain.com
> host1.subdom1.new-domain.com
>
> From what I can see I would need to add a separate rewrite set for each host 
> within the old domain:
>  RewriteCond %{HTTP_HOST} ^service1\.old-domain\.com$ [NC]
>  RewriteRule ^(.*)$  service1.new-domain.com$1  [R=301,L]
>
>  RewriteCond %{HTTP_HOST} ^service2\.old-domain\.com$ [NC]
>  RewriteRule ^(.*)$  service2.new-domain.com$1  [R=301,L]
>  etc...
>   

Assuming that all of them end in old-domain.com, something like this 
should work (untested, but the concept should work):

RewriteCond %{HTTP_HOST} (.*)\.old-domain\.com$ [NC]
RewriteRule ^/(.*)  http://%1.new-domain.com/$1  [R=301,L]


-- 
Justin Pasher

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