I have two URLs pointing to one app and I would like them all to be redirected to the SSL address with www (i.e https://www.example1.com)
I currently have the following in my .htaccess file:
RewriteCond %{HTTP_HOST} ^example1.com [nc,or]
RewriteCond %{HTTP_HOST} ^www.example1.com [nc,or] # Causes problems
RewriteCond %{HTTP_HOST} ^example2.com [nc,or]
RewriteCond %{HTTP_HOST} ^www.example2.com [nc] # Causes problems
RewriteRule ^(.*) https://www.example1.com$1 [R=301,nc]
The conditions for www URLs don’t seem to redirect properly and the browsers complain as much.
Any help is greatly appreciated.
In most Apache SSL setups, your best bet is redirecting Apache traffic on a port other than 443 (SSL) to the SSL URL:
or, you can check for HTTPS this way: