Force website to use https Print

  • https, SSL, Redirect
  • 0

Force website to use HTTPS using .htaccess file

If your website has an SSL/TLS certificate, you can force all visitors to your site to use HTTPS to ensure your traffic is secure.

You can do this by editing your .htaccess file which you can find in the cPanel file manager.

Open up the file and add the following lines:

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

Note. If your using WordPress then your .htaccess file will already have some code in it.
Make sure to add the redirect code only before or after the following lines, never in between:

# BEGIN WordPress

<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>
# END WordPress



Was this answer helpful?

« Back

Powered by WHMCompleteSolution