Last active
April 16, 2016 07:17
-
-
Save richjenks/7c5e52c6b211139ae6ba to your computer and use it in GitHub Desktop.
Clean URLs
This file contains 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> | |
# Force https | |
RewriteCond %{HTTPS} !=on | |
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
# Remove www. | |
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] | |
RewriteRule ^(.*)$ http://%1/$1 [R=301,L] | |
# Enforce trailing slash | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule ^(.*[^/])$ /$1/ [L,R=301] | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment