Created
January 17, 2015 22:10
-
-
Save jmillerdesign/a80bdca5ce3e34322594 to your computer and use it in GitHub Desktop.
Apache add or remove trailing slash for non-file URLs
This file contains hidden or 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
# ---------------------------------------------------------------------- | |
# Add trailing slash to (non-file) URLs | |
# Rewrite "example.com/foo -> example.com/foo/" | |
# ---------------------------------------------------------------------- | |
<IfModule mod_rewrite.c> | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$ | |
RewriteRule ^(.*)$ /$1/ [R=301,L] | |
</IfModule> | |
# ---------------------------------------------------------------------- | |
# Remove trailing slash from (non-file) URLs | |
# Rewrite "example.com/foo/ -> example.com/foo" | |
# ---------------------------------------------------------------------- | |
<IfModule mod_rewrite.c> | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$ | |
RewriteRule ^(.*)/$ /$1 [R=301,L] | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment