We have a client server hosting our web application using Apache 2.2 & Tomcat 6 in RHEL. I have setup apache re-write rule for http to https redirection and it works fine. We have two DNS names that are used to access the same application. Test1.com and Test2.com. I want all the users trying to access http:// test1.com or https:// test1.com to https:// test2.com. As mentioned, http:// test1.com to https:// test2.com redirection is working fine. I am not able to implement https://test1.com to https://test2.com.
I have tried Virtual Hosts, ServerAlias, NameVirtualHost, but nothing works. Any suggestions if we can handles this via re-write would help. Any other pointers that might lead to the resolution of this issue will be appreciated.
Thanks
In Apache, the preferred way to redirect HTTP to HTTPS is to configure the 301 redirect in the domain's virtual host.
Here's how it all boils down: HTTPS is secure, while HTTP is not. The websites that have made the move to redirect HTTP to HTTPS appear with a padlock on the browser bar before the URL.
Try the following:
RewriteEngine On
RewriteCond %{HTTP_HOST} test1.com$
RewriteRule ^(.*)$ https://test2.com$1 [L,NC,R=301]
If you have a <VirualHost>
for both :80
and :443
, this redirect should go in both configurations.
I solved this issue with redirect, but I had to setup virtual host for https redirect with all necessary ssl settings.
<VirtualHost *:80>
ServerName test1.com
Redirect "/" "https://test2.com/"
</VirtualHost>
<VirtualHost *:443>
ServerName test1.com
Redirect "/" "https://test2.com/"
SSLEngine on
# SSLProxyEngine On
SSLCertificateFile /path/site.crt
SSLCertificateKeyFile /path/site.key
SSLCertificateChainFile /path/DigiCertCA.crt
SSLProtocol ALL -SSLv2 -SSLv3
SSLHonorCipherOrder on
SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH
</VirtualHost>
<VirtualHost *:443>
ServerName test2.com
...
SSLEngine on
# SSLProxyEngine On
SSLCertificateFile /path/site.crt
SSLCertificateKeyFile /path/site.key
SSLCertificateChainFile /path/DigiCertCA.crt
SSLProtocol ALL -SSLv2 -SSLv3
SSLHonorCipherOrder on
SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH
</VirtualHost>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With