Skip to content

Instantly share code, notes, and snippets.

@amsgator
Created June 24, 2019 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amsgator/aef668dadb729266a504a6e109957ab7 to your computer and use it in GitHub Desktop.
Save amsgator/aef668dadb729266a504a6e109957ab7 to your computer and use it in GitHub Desktop.
Redirect all traffic to https www in 1 hop
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect all naked http(s) to https www in 1 hop
RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule ^(.*)$ https://www\.domain\.com/$1 [R=301,L]
# Redirect all http www to https www in 1 hop
RewriteCond %{HTTPS} !on [NC]
RewriteRule ^(.*)$ https://www\.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