Skip to content

Instantly share code, notes, and snippets.

@nathos
Created January 26, 2013 22:49
Show Gist options
  • Save nathos/4645164 to your computer and use it in GitHub Desktop.
Save nathos/4645164 to your computer and use it in GitHub Desktop.
tweaked .htaccess for automatically removing (and redirecting) URLs with trailing slashes with Statamic (http://statamic.com).
RewriteEngine On
RewriteRule ^(_app) - [F,L]
RewriteRule ^(_config) - [F,L]
RewriteRule ^(_content) - [F,L]
RewriteRule ^(.*).yml$ - [F,L]
RewriteRule ^(.*).yaml$ - [F,L]
RewriteRule ^(.*).html$ - [F,L]
RewriteRule ^(.*/)?\.git+ - [F,L]
# remove trailing slash from URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} (.*)$
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php [QSA,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment