Redirect HTTP to HTTPS

How to Redirect HTTP Requests to HTTPS with .htaccess

Google is now considering SSL Certificate as a ranking signal among all other factors. So this is ideal to have a HTTPS encryption on your website.

If you have purchased and installed SSL Certificate, you should redirect your website HTTP requests to HTTPS so that your website content loads over an encrypted path ( https:// ).

If you are a VernalWeb customer, you can redirect from HTTP to HTTPS easily using our Force HTTPS Redirect feature in cPanel.

 

How to Redirect HTTP Requests to HTTPS with .htaccess

You can manually enable redirect option for your website using .htaccess. Let’s learn how to do it:

Step 1: Edit/Create a .htaccess file in the folder your site is being served from (normally public_html). You can easily edit the .htaccess file using an FTP client or through the online File Manager in cPanel.

Step 2: Add the following code to the .htaccess file:

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

Step 3: Save the file and check the results in your web browser by trying to access your site using standard HTTP rather than HTTPS.

If it is working correctly, you should be automatically redirected to https.

However, after enabling force redirection, if you are facing mixed content warning, just add this code to your site’s .htaccess file:

<ifModule mod_headers.c>
Header always set Content-Security-Policy "upgrade-insecure-requests;"
</IfModule>

We hope this tutorial helps you find the perfect solution. If your like our tutorials, definitely you’ll love our support. All VernalWeb hosting plans include 24/7 support from our amazing inhouse support staff. Check out our web hosting plans and have your website migrated today!


Posted

in

by