How can i redirect HTTP to HTTPS automatically on my website?

Please log in or register to opinion this Issue.

(6.4k points) · opinion
If you have a secure certificate (SSL) on your website, you can automatically redirect your website visitors to the secured (HTTPS) version to make sure their information is fully protected.

However, the redirection method depends on the type of hosting you have.
+1 vote
(6.4k points) · opinion
Linux & cPanel:
Linux-based hosts use .htaccess files to handle redirection.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]
+1 vote

Comments

(6.4k points) · commented
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.
0
(6.4k points) · commented
Note: you can manage (create or edit) your .htaccess file from Control Panel's "File Manager" tab.
0