Skip to content

Instantly share code, notes, and snippets.

@rakeshsoni18
Created October 22, 2020 09:41
Show Gist options
  • Save rakeshsoni18/11fcff1b3ef1ad2e0c86985d4daeb01f to your computer and use it in GitHub Desktop.
Save rakeshsoni18/11fcff1b3ef1ad2e0c86985d4daeb01f to your computer and use it in GitHub Desktop.
Redirect HTTPS Through .htaccess
# Forcing HTTPS on All Traffic
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Forcing HTTPS on a Specific Domain
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain1.com [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Forcing HTTPS on a Specific Folder
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(folder1|folder2|folder3) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment