Skip to content

Instantly share code, notes, and snippets.

@csdy
Created April 17, 2018 19:35
Show Gist options
  • Save csdy/1b6ac7b2a714067fd2ed578043d1e422 to your computer and use it in GitHub Desktop.
Save csdy/1b6ac7b2a714067fd2ed578043d1e422 to your computer and use it in GitHub Desktop.
.htaccess Cheatsheet
<ifModule mod_rewrite.c>
# Enable mod_rewrite
RewriteEngine On
RewriteBase /
# Rewrite www to non-www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# Rewrite to HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment