Skip to content

Instantly share code, notes, and snippets.

@webdados
Created October 8, 2018 12:10
Show Gist options
  • Save webdados/92c1bfa16fed1a347c21c4b0ad923832 to your computer and use it in GitHub Desktop.
Save webdados/92c1bfa16fed1a347c21c4b0ad923832 to your computer and use it in GitHub Desktop.
.htaccess rules to redirect http to http
# Do NOT use this rules unless you are absolutely sure you do not have any mixed contents issues, or you may be masquerading them
# Redirect from http to https without www
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ https://domain.com/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Redirect from http to https with www
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule (.*) 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