January 17, 2008

The facts about trailing slashes in URLs

You will find other articles relevant to this document in these sections:
Richard Lee @ 2:29 pm

Often when writing URL’s we put little thought into whether we add a trailing slash or not, especially these days with SEO where more concerned about the actual readability of the URL. The fact is webservers differentiate a request for a file and directory through the slash. When an incoming request comes through without a trailing slash even if there’s no extension (i.e. www.mysite.com.au/home) the webserver first tries to  locate a file, only when its checked all files within the given directory does it then go on and check for a directory. While this is minor its still uneccessary overhead on the server when you consider a directory with hundreds of files.

So what does this mean in terms of SEO rewrites? Well not much because you can have whatever URL you want as long as you can translate it via some rule for the server. However, it is something to bear in mind if you dont want to give more meaning to your URLs. For instance, excluding this blog, these days for URL rewrites pointing to collections of things like Categories i usually end my URL’s with slashes category/politics/ and for single files I usually end my URLs with an  2008/01/17/keving07.html

Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • digg
  • Furl
  • Reddit
  • YahooMyWeb

2 Comments »

  1. Also worth pointing out is that apache by default will send a redirect header to the user for a request such as www.blah.com/blah to be replaced by www.blah.com/blah/ so this adds a little to the loading of the page being linked to.

    Comment by David Arthur — February 17, 2008 @ 12:20 am

  2. Thanks for the extra info David, I didnt even think of that :)

    Comment by Richard Lee — February 17, 2008 @ 11:12 pm

RSS feed for comments on this post. TrackBack URI

Leave a comment