Redirect your http site to https

To redirect your http site to https, you can input the following code into your .htaccess file under public_html. Make sure to upload the file into the correct directory.

Redirect your http site to https:

RewriteCond %{HTTPS} off
 # First rewrite to HTTPS:
 # Don’t put www. here. If it is already there it will be included, if not
 # the subsequent rule will catch it.
 RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
 # Now, rewrite any request to the wrong domain to use www.
 RewriteCond %{HTTP_HOST} !^www\.
 RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

NOTE: We do not recommend editing your .htaccess files without professional assistance. A single wrong line in the .htaccess files may affect your whole website.

To install SSL certificate for your website, you may refer to our article about Secure website with SSL.

Rate This Article

(63 out of 132 people found this article helpful)

Leave A Comment?

This site uses Akismet to reduce spam. Learn how your comment data is processed.