Welcome Guest, Not a member yet? Register   Sign In
Should URL's end in a trailing slash?
#1

[eluser]Xeoncross[/eluser]
I have been forcing trailing slashes into all my paths since starting with CI. For example:

Code:
site.com/
site.com/welcome/
site.com/profile/

Thanks to some nice mod_rewriting:

Code:
#  Forces trailing slashes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^(.+)$ $1/ [L,R=301]

However, given the old adage that "directories end in slashes, while files don't" I started questioning my method. After all site.com/profile/ isn't a directory - it's a page. So I am now changing to removing ending slashes from all my pages.

Code:
# Removes trailing slashes
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule ^(.+)/$ $1 [L,R=301]

Any input on which one is the proper method? I really would like to pick one and stick with it.


Messages In This Thread
Should URL's end in a trailing slash? - by El Forum - 09-21-2009, 11:33 AM
Should URL's end in a trailing slash? - by El Forum - 09-21-2009, 01:23 PM
Should URL's end in a trailing slash? - by El Forum - 09-21-2009, 01:35 PM



Theme © iAndrew 2016 - Forum software by © MyBB