Skip to content

Instantly share code, notes, and snippets.

@JackNUMBER
Created November 15, 2020 21:56
Show Gist options
  • Save JackNUMBER/ca2840d32b5a9fcc88247b890c611988 to your computer and use it in GitHub Desktop.
Save JackNUMBER/ca2840d32b5a9fcc88247b890c611988 to your computer and use it in GitHub Desktop.
HTTP to HTTPS + removing WWW subdomain
RewriteEngine On
# rule for forcing https
RewriteCond %{HTTPS} off [OR]
# rule for removing www subdomain
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment