Website HTTP to HTTPS with .htaccess

Website HTTP to HTTPS

On this page you’ll know how to force website from HTTP to HTTPS protocol with .htaccess file. You website’s each user will be automatically redirected from HTTP to HTTPS protocol. As you know, HTTPS is used to secure communication over a web network & is widely used on the Internet for websites. Therefore, in order to increase the security & SEO of your website, you must divert all of your website’s traffic to HTTPS protocol.

HTTPS protocol does not only make more secure but it also necessary for your website’s SEO (Search Engine Optimization). Search engines prefer users security, therefore websites with HTTPS get more importance. Forcing the web traffic from HTTP to HTTPS using .htaccess is as easy as ABC… Let’s know how!

Website HTTP to HTTPS with .htaccess

Once you’ve installed SSL certificates for your website, you can use HTTPS protocol on your website. One of the most important files .htaccess performs numerous important functions for your website. Some of the important functions that .htaccess performs include; redirections, error handling, protection, blacklisting, whitelisting & creating default File for a directory etc.

  • 💡 Where is .htaccess file Available?
    • Normally, .htaccess file is available in your website’s root folder. The root folder is usually named public_html.

We assume you’ve found your website’s .htaccess file. Let’s start the main process!

1. Download it & open with notepad++ or any other your favorite editor. Or Go to File Manager in your hosting panel inside the public_html folder. To open it, right click on .htaccess & click on “Edit”.

Edit File

2. After opening it, scroll down to the end of the file & copy paste the following code lines below at the end:

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

3. Save changes.

Save File

That’s all, you’re done!

Closure

Congrats! now your website’s each user will sea your website’s each page with HTTPS protocol. As, your website’s traffic will land & surf on safe version of your website. In case of further queries, feel free to comment or contact us.

We will be happy to hear your thoughts

Leave a reply

AHTech.com.pk
Logo