Forcing HTTPS

The best way we've found to send requests to HTTPS is this:

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]

Copy and paste these lines at the top of your .htaccess file. This works for any domain/sub-domain, since Apache will replace %{SERVER_NAME} with the domain of the current request.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Fixing Referrer Spam in .htaccess

Are your web analytics full of low quality referrals? If you made the mistake of signing up for a...

Letting AutoSSL get past a protected directory

There are many reasons why you want to protect a subdomain or directory from the public. You...