26 Oct 2006, 1:02 p.m.

URL File Extensions Considered Harmful

A recent conversation with a colleague reminded me of just how much I hate seeing programming language file extensions in URLs. You know - .php, .asp, .cfm and the like. There are several reasons why we avoid them like the plague.

First off, what happens when we change platform from PHP to ASP/Ruby/some other language? You have the choice of scrapping your existing URL schema (considered harmful), setting up a whole lot of redirects or rewrites, or maintaining a naming convention that no longer represents your platform.

It sounds unlikely to happen - how often does a non-trivial site or app migrate to a whole new development platform? Well, anyone who has worked in the industry for more than a few months knows the answer to that. PropertyMall (just an example) has moved from static HTML to Perl to PHP3, 4 and 5 in its lifetime. As a result, we're stuck with lot of rewrite rules supporting legacy URLs, but next time it happens, there will be one less thing to worry about.

There's a more academic objection, based on the very essence of HTTP and the web. Now, if I request a resource ending in .xls, I want to receive a spreadsheet, right? So, if I request a file ending in .php, I want to be served some PHP code! But what I get is HTML. Well, OK...so should the URL end in .html? Maybe - but that breaks down too, say, if we were to dynamically send HTML/WML/XML/etc depending on whether the agent is a web browser, or a phone, or an internet-ready washing machine. HTTP is designed to take care of that stuff for us, so we should never be relying on file extensions.

Aside from that, I can't help but feel that it just looks clumsy and amateurish: it certainly betrays the fact that the author simply doesn't know how to decouple the URL schema from the filesystem - a WTF in itself. There's also some debate about whether Google (etc) really 'likes' pages that it believes to be dynamic, and therefore likely to change. That said, one thing I won't be discussing in detail here is SEO: there's enough blogs about that sort of thing already.

Posted by Simon at 01:53:00 PM