Redirect HTTP Requests to HTTPS

.htaccess 101 – Redirect HTTP Requests to HTTPS

Once you have purchased and installed an SSL Certificate, you should automatically redirect visitors to the secure version of your website ( https:// ).

This ensures data sent to and from your website is securely encrypted. Besides this, according to Google – HTTPS is now a ranking signal among some other factors.

If you are a Biz2rock customer, you can easily redirect HTTP to HTTPS requests using the force HTTPS redirect feature in cPanel.

How to Manually Redirect HTTP Requests to HTTPS using .htaccess

However, if for some reason your website is not working after you enabled the force redirect in cPanel, you should try to do this via your .htaccess file.

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.

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

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

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.

Please Note: If you do not have an SSL certificate installed, this could cause errors. Please make sure that you have an SSL certificate installed and properly working before attempting this.

How to fix mixed content warnings (insecure requests)

Once doing the redirect from HTTP to HTTPS, if you are facing SSL mixed content warnings, you only need to add the following lines of code to your site’s .htaccess file:

# BEGIN Fix mixed content warnings
<ifModule mod_headers.c>
Header always set Content-Security-Policy "upgrade-insecure-requests;"
</IfModule>
# END Fix mixed content warnings

As always, our customer support team is here to answer any questions you may have!

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to Fix Error: No specific error was returned with the failed API call

How to Fix Error: No specific error was returned with the failed API call |FIXED| Today in this...

How to Install SSL in cPanel

In this tutorial, you will learn how to install SSL using Let’s Encrypt SSL utility in Cpanel for...