Skip to content

Instantly share code, notes, and snippets.

@geokarbou
Last active July 12, 2018 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geokarbou/7f56e9b6b53c2d2141a5d294ebf2ed0f to your computer and use it in GitHub Desktop.
Save geokarbou/7f56e9b6b53c2d2141a5d294ebf2ed0f to your computer and use it in GitHub Desktop.
Enforcing trailing or no-trailing slash policy .htaccess
/*** enforce a no-trailing-slash policy ***/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R]
/*** enforce a trailing-slash policy ***/
RewriteEngine on
RewriteRule ^([^.]*[^/])$ $1/ [R=301,L,NE]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment