• Services
    • Web Hosting
    • Reseller Hosting
    • VPS Hosting
    • Dedicated Hosting
  • Domains
  • Features
  • Company
    • About Us
    • Server Locations
    • Affiliates
    • Company Blog
  • Support
  • Client Login
  • Services
    • Web Hosting
    • Reseller Hosting
    • VPS Hosting
    • Dedicated Hosting
  • Domains
  • Features
  • Company
    • About Us
    • Server Locations
    • Affiliates
    • Company Blog
  • Support
  • Client Login
Home/Article/Web Hosting/.htaccess/How to Redirect HTTP Requests to HTTPS with .htaccess

How to Redirect HTTP Requests to HTTPS with .htaccess

Written by VernalWeb
March 21, 2020

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!

Tags:htaccess

Was this helpful?

Yes  No
Related Articles
  • How to create or edit .htaccess file in cPanel
  • How to enable hotlink protection using .htaccess Code
  • How to create custom 404 page using .htaccess
  • How to Create SEO Friendly URL Using .htaccess
  • How to create 301 redirection using .htaccess
  • How to force SSL using .htaccess file

Didn't find your answer? Submit Ticket

Latest Articles

  • How to show Hidden Files (.htaccess) in cPanel File Manager
  • Setup a Domain Redirection in cPanel
  • Create a MySQL Database and a User from cPanel
  • Remove page extensions using .htaccess
  • Cron Job Usage & Policy
  • © 2014 - 2025 VernalWeb. All rights reserved.