How to force SSL with .htaccess

Using the following code in your .htaccess file automatically redirects visitors to the HTTPS version of your site:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

If you have an existing .htaccess file:

- Do not duplicate RewriteEngine On.
- Make sure the lines beginning RewriteCond and RewriteRule immediately follow the already-existing RewriteEngine On.
  • ssl, htaccess
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to force SSL with cPanel

If you wish to force SSL via cPanel follow this steps:    - log into your cPanel account and...

How to force SSL with CloudFlare

Forcing SSL via CloudFlare follow this steps: - Login into your CloudFlare account, choose the...

Powered by WHMCompleteSolution