How to Redirect HTTP to HTTPS Using. htaccess?

How to Redirect HTTP to HTTPS Using. htaccess?

Chrome and Firefox have started showing insecure warnings on sites without SSL certificates. Without SSL, your website will show insecurity to the visitors. Therefore, using an SSL-encrypted connection for safety, accessibility, or PCI compliance reasons is important. Google is now considering SSL Certificate as a ranking signal among all other factors. So this can be ideal to possess HTTPS encryption on your website. It becomes important to redirect from HTTP to HTTPS.

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

you can redirect from HTTP to HTTPS easily follow the steps.

Also Read: What is cPanel?

Editing .htaccess in cPanel File Manager

Note: Backup your website in case something goes wrong.

  1. Login to cPanel.
  2. Files > File Manager > Document Root for.
  3. Now select the domain name you want to access.
  4. Check “Show Hidden Files (dotfiles)”.
  5. Click “Go”.
  6. After a new tab or window opens, look for the .htaccess file.
  7. Right-click on the .htaccess file and click on “Code Edit” on the menu.
  8. A dialogue box may pop up asking about encoding. Click the “Edit” button to continue.
  9. Edit the file.
  10. “Save Changes” when done.
  11. Test your website to make sure it is done correctly. In case, there is an error, restore to the previous version and try again.
  12. Once you are done, click “Close” to close the window.
Also Read: Most Popular Control Panels.
How to Redirect HTTP to HTTPS Using. htaccess?

Redirect HTTP to HTTPS 

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

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

Step 2: Add this 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 browser by trying to access your site using standard HTTP instead of HTTPS.

If it’s working correctly, you must be automatically redirected to https.

However, after enabling force redirection, if you’re facing a 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>
Also Read: How To Change PHP Versions And Settings Using PHP Selector?

What is SSL?

SSL (Secure Sockets Layer) is a standard security protocol for establishing encrypted links between a website server and a browser in online communication.

The usage of SSL technology ensures that every one data transmitted between the website server and browser remains encrypted.

An SSL certificate is important to make an SSL connection. you’d got to give all details about the identity of your website and your company as and once you prefer to activate SSL on your web server. Following this, two cryptographic keys are created — a private key and a Public Key.

Also Read: How To Create Or Edit Htaccess File In cPanel?

Create A Beautiful Website

You want to create a website for your business click the below button.

Buy Best Hosting For Website

Hostguid listed many hosting plans so you can easily compare many hosting companies hosting packages for your website.

Join Our Whatsapp Group

Upcoming hosting and SSL offers and news updates here. We can try to solve your doubt regarding any problem like Domain, Hosting, SSL certificate, etc. And News update here.

Join Our Telegram Group

Upcoming hosting and SSL offers and news updates here. We can try to solve your doubt regarding any problem like Domain, Hosting, SSL certificate, etc. And News update here.

This article helpful?
YesNo
Default image
Host Guid
Articles: 53

3 Comments

  1. Admiring the commitment you put into your blog and in depth information you provide.

    It’s awesome to come across a blog every once in a while
    that isn’t the same unwanted rehashed material.
    Wonderful read! I’ve bookmarked your site and I’m including
    your RSS feeds to my Google account.

Leave a Reply

Open chat
1
Hii, How can I help you?