Skip to content

Instantly share code, notes, and snippets.

@royce002
Created March 4, 2021 22:14
Show Gist options
  • Save royce002/dcba7d5ae41b4afb29e300aa5bd28205 to your computer and use it in GitHub Desktop.
Save royce002/dcba7d5ae41b4afb29e300aa5bd28205 to your computer and use it in GitHub Desktop.
.htaccess script to redirect all traffic to https with no wwws.
# Redirect to https and non-www
# Canonical HTTPS/non-WWW
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule (.*) https://example.com/$1 [L,R=301]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment