• 24x7 Technical Support
  • +91-9999943885

How to redirect HTTP to HTTPS Using .htaccess

redirect HTTP to HTTPS

Want to create a redirect from HTTP to HTTPS? See this step by step guide on how to force all visitors and traffic to HTTPS using htaccess.

Way To edit an .htaccesss file

1. Redirect Only a Specific Domain
> For redirecting a specific domain to use HTTPS, add the following:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomainname\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomainname.com/$1 [R,L] 

2. Redirect All Web Traffic
> If you have existing code in your .htaccess, add the following:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomainname.com/$1 [R,L]

3. Redirect Only a Specific Folder
> Redirecting to HTTPS on a specific folder, add the following:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$ https://www.yourdomainname.com/folder/$1 [R,L]