Skip to content

Instantly share code, notes, and snippets.

@EpocSquadron
Created August 28, 2013 14:30
Show Gist options
  • Save EpocSquadron/6366641 to your computer and use it in GitHub Desktop.
Save EpocSquadron/6366641 to your computer and use it in GitHub Desktop.
Htaccess snippet for forcing trailing slash at the end of urls.
# ------------------------------------------------------------------------------
# | Suppressing / Forcing the "/" at the end of URLs |
# ------------------------------------------------------------------------------
# Place this underneath the 'Suppressing / Forcing the "www."'
# section of the h5bp file, or just ensure it occurs before the
# index.php rewrite.
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ $1/ [R=301]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment