Redirect HTTP Requests to HTTPS Using .htaccess

Redirect All Traffic to HTTPS

To redirect ALL http requests to https, add the following lines to the .htaccess file located in the root directory (typically located at /public/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 ALL http URL requests to https for a specific Domain Name, add the following lines to the .htaccess file located in the root directory (typically located at /public/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 /public/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 Domains and folder names to be redirected.

Hjälpte svaret dig?

 Skriv ut denna artikeln

Läs även

View and Manage Domain Backorders

This article will provide a quick guide to viewing and managing your Domain Backorders. Domain...

How to Edit Zone File and Setup DNS Forwarding

To perform DNS forwarding, change your zone file, (MX, A-Records & CNAME) using the...

Fix Corrupted named.conf in cPanel

Sometimes named.conf gets corrupted on cPanel server. Here is the way to fix that in cPanel...

508 Resource Limit is Reached

If your website is using a shared hosting acount, you may have noticed the following error...

Fix Corrupted named.conf in cPanel Server

This article provides a resolution in case you experience a corrupted named.conf file on a cPanel...