Created
April 17, 2018 19:35
-
-
Save csdy/1b6ac7b2a714067fd2ed578043d1e422 to your computer and use it in GitHub Desktop.
.htaccess Cheatsheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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