Here is my situation: I have two CNAME domains (domain.one.com
and domain.two.com
) that point to the same IP/machine and I want to redirect one of the two to the other one, like domain.one.com/anything
to domain.two.com/anything
. domain.two.com
has a valid SSL certificate, if it matters.
And I have the following settings:
In httpd.conf
:
RewriteCond %{HTTP_HOST} ^domain\.two\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) https://domain.two.com/$1 [L,R]
NameVirtualHost *:80
NameVirtualHost domain.two.com:443
<VirtualHost *:80>
ServerName domain.two.com
DocumentRoot "/var/www/html/"
ErrorLog logs/error_log
CustomLog logs/access_log common
RewriteEngine On
RewriteOptions Inherit
</VirtualHost>
In ssl.conf
:
<VirtualHost domain.two.com:443>
DocumentRoot "/var/www/html"
ServerName domain.two.com:443
</VirtualHost>
--
What I have tried so far:
Adding to httpd.conf
the following:
NameVirtualHost domain.one.com:443
<VirtualHost domain.one.com:80>
ServerName domain.one.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.one.com$
RewriteRule (.*) http://domain.two.com/$1 [R=Permanent]
</VirtualHost>
- Doesn’t redirect.
Also adding the following to ssl.conf
:
<VirtualHost domain.one.com:443>
ServerName domain.one.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.one.com$
RewriteRule (.*) http://domain.two.com/$1 [R=Permanent]
</VirtualHost>
- The server stops working.
I know I’m doing something wrong, but I don’t know what. How can I make this work?
(I should mention that I’m a noob in these things.)