flag of the United Kingdom
Search:  

Revised URL Schema

Date:  17th July, 2004prevnext

I have followed a couple of discussions pertaining to URLs over the past few days.

As a result of various articles and their respective comments, I have made a few subtle changes to the URL schema of urbanmainframe.com...

The Trailing Slash as Best Practise

It all started with "Slash Forward (Some URLs are Better Than Others)" over at A List Apart. This is an old article (22nd February, 2002) but as relevant today as it was when it was first written.

In the article Waferbaby tells us that, "a frequently overlooked step in [the process of building a website] is the structure of your links - the actual URLs you'll be using to point to items on your site."

Waferbaby advises us that URLs should feature a trailing slash and that technology-specific file extensions (".htm", ".php", ".cgi", etc.) should not be used. He furnishes us with two good reasons why:

  • expandability - suppose you change the underlying platform behind your website, substituting Perl for PHP for example (and why wouldn't you?)... If you are using a generic URL schema ("/about/" rather than "/about.php") then your internal links need no adjustment to accommodate the change. More importantly external links and bookmarks will still work. Otherwise you'd better be prepared for a tedious session with mod_rewrite in order to maintain link integrity. Remember: Cool URIs Don't Change!
  • security - for various reasons, it's always better to avoid revealing too many details of a website's technology, lest the wrong kind of person decides to exploit it.

One more issue that Waferbaby touches on is that web-server performance can suffer (slightly) when the trailing "/" is omitted.

Next came Mike Papageorge (fiftyfoureleven.com) who asked for advice on "Trailing Slashes Best Practise" while pointing out that there are many "inconsistencies amongst the ranks". Simon Jessey responded, telling us that he has "adopted a policy of always having the trailing slash". Jessey also pointed out that the highly respected Simon Willison advocates the trailing slash, which is a little strange since Papageorge had already highlighted Willison's weblog as one within which URLs don't always end with "/" (example)!

The upshot of all this is that I have begun the process of implementing URLs with trailing slashes on this website.

The New Schema

I have removed the extraneous requirement for urbanmainframe.com URLs to end with "/index.htm" and "/page_1.htm". Where these URLs were used previously, a simple "/" will now suffice.

Examples:

Note: The old addresses are still perfectly valid and remain functional. Links/bookmarks using the old schema will still retrieve the correct page - mod_rewrite will automatically rewrite them with the new variant.

Where documents span multiple pages, the "/page_x.htm" suffix is still required, for the time being.

Work in Progress

I should point out that there are probably still modules in my CMS that use the old schema. Furthermore, there are many URLs that I haven't yet done anything with. I will revise these as and when I notice them, working towards 100% adoption of URLs without file-type extensions and ending with "/".

Naturally, I'll be keeping a lookout for 404 errors in my logs. However, if you find that I've broken something then please let me know, either in the comments for this article, or by email.

Related Reading

You can comment on this entry, or read what others have written (3 comments).

W3C VALIDATE XHTML
W3C VALIDATE CSS