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.

Помог ли вам данный ответ?

 Распечатать статью

Также читают

How to Flush DNS Cache

Flushing your DNS cache can be useful when the information about a domain you hold is outdated,...

Assigning a Dedicated IP Address to a Subdomain using WHM

To assign a dedicated IP address to a subdomain, perform the following steps: Step 1: Add the...

How to Generate/Download a Full Backup in cPanel

A full backup is a backup of all of your entire cPanel Shared Hosting account (files, email,...

Disabling mod_security in cPanel

Mod_security is an apache module that helps to protect your website from various attacks. It is...

Create Alias Domain in cPanel

This article outlines how to create an Alias Domain in cPanel Adding a Domain Alias To add a...