Skip to content

Instantly share code, notes, and snippets.

@amsgator
Created June 24, 2019 23:21
Show Gist options
  • Save amsgator/49a42a93251080888e8930eb9439f097 to your computer and use it in GitHub Desktop.
Save amsgator/49a42a93251080888e8930eb9439f097 to your computer and use it in GitHub Desktop.
Redirect all traffic to naked https in 1 hop
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect all http to naked https in 1 hop
RewriteCond %{HTTPS} !on [NC]
RewriteRule ^(.*)$ https://domain\.com/$1 [R=301,L]
# Redirect all https www to naked https in 1 hop
RewriteCond %{HTTP_HOST} ^www\.domain\.com [NC]
RewriteRule ^(.*)$ https://domain\.com/$1 [R=301,L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment