1. Home
  2. Hosting Management
  3. cPanel
  4. Domains
  5. .htaccess 101 – 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 ChemiCloud 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!

Updated on January 14, 2021
Was this article helpful?

Related Articles

Spring into Savings!
Up to 78% Off Hosting Plans + Free Migration!
👉 View Deals

Comments

  1. You have worked hard on your website. You have helped us a lot through this post, we hope that you will continue to write such informative posts in the future also. Which will benefit many people.

Leave a Comment