Skip to content

Instantly share code, notes, and snippets.

@benlilley
Created April 22, 2018 22:47
Show Gist options
  • Save benlilley/cfc78002013212df85bf4de7ef4a536b to your computer and use it in GitHub Desktop.
Save benlilley/cfc78002013212df85bf4de7ef4a536b to your computer and use it in GitHub Desktop.
Default Craft CMS .htaccess
# ----------------------------------------------------------------------
# | Cleaning URLs |
# ----------------------------------------------------------------------
<IfModule mod_rewrite.c>
RewriteEngine On
# Remove www from URL's
RewriteCond %{HTTP_HOST} ^www\.(.+)
# RewriteCond %{HTTPS}s/%1 ^(on(s)|offs)/(.+)
RewriteRule ^ http%2://%3%{REQUEST_URI} [L,R=301]
# Make all traffic go over https
# RewriteCond %{HTTP:X-Forwarded-Proto} !https
# RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Remove trailing slashes
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Send would-be 404 requests to Craft
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
RewriteRule (.+) index.php?p=$1 [QSA,L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment