Skip to content

Instantly share code, notes, and snippets.

@ixkaito
Last active April 8, 2020 05:59
Show Gist options
  • Save ixkaito/ea39aff3e53a47b5abef91735f145395 to your computer and use it in GitHub Desktop.
Save ixkaito/ea39aff3e53a47b5abef91735f145395 to your computer and use it in GitHub Desktop.
Redirect non-www to www and HTTP to HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^(.*)$ https://www.%1/$1 [R=301,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment