Forum Moderators: phranque
RewriteEngine On
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^example\.com
RewriteRule (.*) https://example.com/$1 [R=301,L] RewriteEngine On
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^https://example\.com
RewriteRule (.*) https://example.com/$1 [R=301,L] RewriteCond %{SERVER_PROTOCOL} !=HTTPS [OR]
RewriteCond %{HTTP_HOST} !=example.com
RewriteRule (.*) https://example.com/$1 [R=301,L] RewriteCond %{HTTP_HOST} . RewriteCond %{HTTPS} on The first RewriteCond is only needed if your server is accessible via HTTP/1.0. True HTTP/1.0 requests do not include the hostname header, so this RewriteCond prevents (big) problems if the request is HTTP/1.0 and the hostname is blank. You can remove this line if you are on a shared name-based server, since such servers cannot be reached with a blank hostname.
I got the first rewrite condition in a post from jdMorgan:
using %{SERVER_PROTOCOL}
RewriteEngine On
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^example\.com\.au [OR]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://example.com.au/$1 [R=301,L] [edited by: engine at 9:46 am (utc) on May 10, 2013]
[edit reason] examplified [/edit]
RewriteCond %{HTTP_HOST} !^example\.com\.au !^example\.com\.au(:1234)?$