Whenever someone visits intern.old-company-name.example.com
I would like it to get redirected to https://intern.new-company-name.example.com
. One way to do it would be
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*) https://intern.new-company-name.example.com$1
# RewriteRule ^(.*) https://%{HTTP_HOST}$1
</IfModule>
but I don't like that I hardcode the outer sub domain intern
into the httpd.conf
.
Question
Would it be possible to do a regex on %{HTTP_HOST}
so old-company-name
gets replaced with new-company-name
before the redirection to https
? Or perhaps something similar?
Update
# apachectl -S
VirtualHost configuration:
10.10.10.10:443 is a NameVirtualHost
default server a.y.b.com (/etc/httpd/conf.d/ssl.conf:85)
port 443 namevhost a.y.b.com (/etc/httpd/conf.d/ssl.conf:85)
Syntax OK