mod_rewrite forcing a hostname + https
I'd like to have all requests given to my server rewritten to https instead, and also force a specific hostname. I want all requests issued to the server to be rewritten to https://mail.mydomain.com. For example, if somebody types in mail.theirdomain.com, I want the request to be rewritten to https://mail.mydomain.com instead.I have the following rules in httpd.conf...
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mail\.
RewriteCond %{HTTP_HOST} !^mail\.mydomain\.com [OR]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*)$ https://mail.mydomain.com/$1 [R=301,L]
I also have the following rules in ssl.conf...
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mail\.
RewriteCond %{HTTP_HOST} !^mail\.mydomain\.com
RewriteRule ^/(.*)$ https://mail.mydomain.com/$1 [R=301,L]
With the rules I have, I get the following results....
When I put in https://mail.theirdomain.com, I get a certificate error but as soon as I click OK and accept the cert, the URL is successfully rewritten to https://mail.mydomain.com as desired.
Now, when I put in anything else, such as...
mail.mydomain.com
http://mail.theirdomain.com
http://mail.mydomain.com
I get browser timeouts. Nothing happens. No pages are loaded. I have also specified a RewriteLog and RewriteLogLevel in my httpd.conf, but nothing ever shows up in the log file.
Any ideas what could be wrong here?