Force HTTPS Using .htaccess

To force all traffic to your domain to use https you can place the following into your .htaccess in your sites root folder, public_html:

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
Make sure that you replace www.example.com with your domain name.

If for some reason you need your site to appear only on http then you can use the following instead:

RewriteEngine On 
RewriteCond %{SERVER_PORT} 443 
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
  • ssl, https
  • 1 Users Found This Useful
Was this answer helpful?