Coding with Jesse

A URL is forever

March 21st, 2006

The golden rule of URLs: They never change.

This certainly isn't a new topic. In fact, it's as old as the web itself. It seems like it's been long forgotten, brushed off and ignored. It is still highly relevant and can't be stressed enough.

When designing URLs, assume they will be still be used 1000 years from now. Why? People already assume they won't change. They bookmark the page, search engines index the page, other sites link to the page. It's your responsibility to keep the page there.

Web applications, search engines, online shopping and sadly even simple web sites have designed URLs to be disposable, full of variables including session IDs and other junk. How often have you sent or received a URL that didn't work because the "session has timed out" or some other reason?

You can improve the permanence of a URL by making it as simple as possible. Try not to include a file extension (.html, .php, etc.) Try to split things up into a logical hierarchy. Using dates in the URL like /2006/3/ can help a site grow over time, but so can using a unique ID such as a number or title.

Sometimes URLs just have to change. Perhaps the original URL was one of those temporary, junk-filled ones and you are migrating to a permanent URL system. When this happens, make sure you put something in place to send the visitor to the new location.

There is already a great document written on this topic, so rather than repeat everything, I will include it here. I highly suggest you read it if you haven't yet:

W3C: Cool URIs don't change

About the author

Jesse Skinner Hi, I'm Jesse Skinner. I'm a self-employed web developer with over two decades of experience. I love learning new things, finding ways to improve, and sharing what I've learned with others. I love to hear from my readers, so please get in touch!