How-to-redirect-HTTP-to-HTTPS-my-info-adda

Redirecting HTTP to HTTPS using .htaccess

 

.htaccess file is available in root directory (EX. Login into Cpanel > File Manager > public_html ) if in case .htaccess file is not available you can create file with name .htaccess

 

If you want to Redirect All Web Traffic to Https URL

In .htaccess file add the following code:

 

RewriteEngine On

RewriteCond %{SERVER_PORT} 80

RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]

 

 

If you want to Redirect only a Specific Domain

In .htaccess file add the following code:

 

RewriteEngine On

RewriteCond %{HTTP_HOST} ^yourdomain\.com [NC]

RewriteCond %{SERVER_PORT} 80

RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]

 

If you want to Redirect Only a Specific Folder

In .htaccess file add the following code replace folder with your folder name

RewriteEngine On

RewriteCond %{SERVER_PORT} 80

RewriteCond %{REQUEST_URI} folder

RewriteRule ^(.*)$ https://www.yourdomain.com/folder/$1 [R,L]

 

 

You may also like