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
[R]at the end? The https rewrite won't create an SSL request any other way and it changes the meaning of the other rewrite rule significantly. – Ladadadada Feb 14 '14 at 18:55[R]flag is fine. The rule I posted were just my current solution, which I would like to make more generic. I.e. without hardcoding theinternsub domain. Hard codingnew-company-name.example.comis fine. – Jasmine Lognnes Feb 15 '14 at 10:49a.x.b.comtohttps://a.y.b.comwhere hard codingy.b.comis fine. I would like to avoidabeing hard coded. – Jasmine Lognnes Feb 15 '14 at 10:56