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.

Cette réponse était-elle pertinente?

 Imprimer cet article

Consultez aussi

Locating php.ini file

A critical file you often need to manage is the php.ini file. It controls many import aspects of...

Slow WHMCS Domain Spinner Whois Lookup

Slow WHMCS domain lookups are a source of frustration for some clients, as this, in turn, leads...

Guide to Domain EPP Codes

EPP Codes are used by Domain Registries to signify the status of domains listed within the...

Create Site Backup Using Backup Wizard

For new users of cPanel the easiest method of backing up your site is to use the Backup Wizard,...

Video: Setup Email Forwarder in cPanel

View our Step-by-Step Tutorial Video for Setting up an Email Forwarder in cPanel Shared Hosting.