This article provides a guide for redirecting HTTP traffic to HTTPS using your website's .htaccess file.
Redirect All Traffic to HTTPS
To redirect ALL http requests to https, add the following lines to the .htaccess file located in the document root directory (for instance, /home/account_name/public_html/.htaccess):
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
Force Specific Domain Traffic to HTTPS
To redirect http URL requests to https for a SPECIFIC DOMAIN, add the following lines to the .htaccess file located in the document root directory (typically located at /home/account_name/public_html/.htaccess):
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
Force Specific Folder Traffic to HTTPS
To redirect http URL requests to https for a SPECIFIC FOLDER, add the following lines to the .htaccess file located in the appropriate directory (typically located at /home/account_name/public_html/specific_folder/.htaccess):
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$ https://www.example.com/folder/$1 [R,L]
Tip: Make sure to replace the example data, www.example.com/folder with the appropriate domain and directory.

👀 Choose SSD-powered VPS servers for increased speed, power, and security! Now 50% off- starting from only $3.19/mo.