How to redirect HTTP to HTTPS using the .htaccess rule

Jan 7, 2021 4:33 pm
by Alex

In WordPress you can have plugins to do the redirection, but when you self host your own application, you can add the following rules to redirect HTTP traffic to HTTPS protocol.

First you need to make sure your have set up your HTTPS certificate.

Login to your host to access the file system, you can use FTP or CPanel file manager.

Locate your website folder, find the .htaccess file

add the following rules to the file to redirect traffics.

# Redirecting HTTP to HTTPS
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$$1 [R,L]