httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pete Nesbitt <>
Subject [users@httpd] Rewrite: modify http_host for many subdomains
Date Wed, 20 May 2009 20:04:27 GMT
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:

I need to make them read:

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 ^(.*)$$1  [R=301,L]

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

I am searching for a method to do this with a single rule.

I have tried adding shell type variable substitution but that fails:
 NEWDOM=`echo %{HTTP_HOST}|sed s/old-domain/new-domain/`
 RewriteRule ^(.*)$ ${NEWDOM}$1 [R=301,L]

Any help would be appreciated.


The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message