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.

Ця відповідь Вам допомогла?

 Роздрукувати цю статтю

Також прочитайте

Video: Setup Email Autoresponder in cPanel

View the Step-by-Step Tutorial for Setting up an Email Autoresponder in cPanel Shared Hosting.

How to Flush DNS Cache in Windows 10

Flushing the DNS resolver cache can help resolve DNS related problems in Microsoft Windows 10....

How to Update DNS Nameservers at GoDaddy

After purchasing our hosting account, you will receive a Welcome email from us which contains our...

Video: Create a Domain Redirect in cPanel

This video tutorial provides Step-by-Step instructions for using MySQL databases in cPanel Shared...

How to Clear Your DNS Cache

Overview Your DNS cache stores the locations (IP addresses) of web servers that contain web...