Home How to How to Force HTTP traffic to HTTPS using .htaccess file

How to Force HTTP traffic to HTTPS using .htaccess file

by wikky

The code Below is to Force all traffic of your website from HTTP request to HTTPS using .htaccess file once you have configured your SSL. Open your .htaccess file located on root of your web directory. If not shown in the files then change setting to view hidden files in web directories (shown image below).

show-hidden-files in-cpanel files-manager

Add following lines to your .htaccess file under <IfModule mod_rewrite.c> tag.

RewriteCond %{REQUEST_URI} !^/[0-9]+..+.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/.well-known/pki-validation/[A-F0-9]{32}.txt(?:\ Comodo\ DCV)?$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Now check your website by entering http://domain.com, you will see your website is redirected to https:// protocol.

Hope this help!

Posts you may like:

    You may also like


    Zachery July 1, 2021 - 7:02 am

    Yes! Finally something about website.

    Cameron July 6, 2021 - 7:58 pm

    Excellent way of telling, and fastidious piece of writing to take information about my presentation subject matter, which i am going
    to deliver in college.


    Leave a Comment

    This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More