I <3 Steve McConnell*
Coding Horror
programming and human factors
by Jeff Atwood

September 29, 2004

Don't Devalue the Address Bar

I was reading an interesting entry in Rocky Lhotka's blog when something in the url caught my eye:

http://www.lhotka.net/WeBlog/PermaLink.aspx?guid=b28971dc-ac4b-4494-8a21-7a5105a39b07
I guess it's a DasBlog thing, but good lord: a globally unique ID in a blog hyperlink? Has it really come to this?

        Dim g As Guid = Guid.NewGuid
        Console.WriteLine(g.ToString)
       
        2ac6857d-6fa4-43f6-9145-dfffaf00fd7a

This is my GUID. There are many like it but this one is mine. My GUID is my best friend. It is my life. I must master it as I must master my life. Without me, my GUID is useless. Without my GUID I am useless.

It's bad enough that so many websites devalue the address bar with nonsensical geek-speak URLs...

.. without adding GUIDs to the mix! How about something simpler that's actually understandable?

Building crappy URLs is just plain laziness. With the rich set of tools provided by IIS and ASP.NET, we should be leveraging 404 handlers and URL Rewriting to build URLs that are simple for people to understand, instead of taking the low road and building URLs that are easy for machines to understand.

My favorite technique is to map the 404 handler in IIS, per website, to /404.aspx. I can then intercept page not found errors with ASP.NET code and Server.Transfer them as I see fit. If you want a more robust solution at the ISAPI level, we've also used ISAPI Rewrite with great success.

* They should simplify this even further by making the default folder handler "index.x", then just.. http://www.techreport.com/etc/2004q3/3dmark05/?pg=1

Posted by Jeff Atwood    View blog reactions
« Why Your Code Sucks... and Mine Doesn't
An ASP.NET CAPTCHA Server Control »
Comments

Simple URLs are great when your content is organized hierarchically and your URLs are hackable. If you hack

hurricane.ivan/index.html

off of the cnn.com URL,

http://www.cnn.com/2004/WEATHER/09/11/

you might expect to find weather information for September 11, 2004. However, neither the cnn.com URL nor the techreport.com URL are hackable. Not great examples.

If your URLs aren't hackable, there isn't much point in making them simple, unless maybe you're storing or exchanging them without metadata.

Colin on September 29, 2004 11:30 PM

One could make a fairly strong argument that URLs really don't matter anymore. How does most of the net population find things? Google. Does the URL matter when they use a bookmark or favorite? Nope.

Aaron on September 29, 2004 11:41 PM

cnn.com's URL looks like it's more for cosmetics than actual function. I know that when I have that URL in my address bar that I'm looking at September 11th, 2004 weather information.

Simple URLS are also easier to remember. You don't always have your favorites or bookmarks handy (though things like furl make this easier). That's why those URL shrink sites are more popular. They take an insanely long and complex URL and shorten it into something that's somewhat easier to remember.

Jeremy Brayton on September 30, 2004 1:04 AM

hey man, first check the url of YOUR post:

http://www.codinghorror.com/blog/archives/000093.html

why can't it be:

http://www.codinghorror.com/DontDevalueAddressBar.htm

????? You're as lazy as the ones you critizise.

CS' on September 30, 2004 5:10 AM

Here&rsquo;s an effective piece on this subject: http://www.w3.org/QA/Tips/uri-choose

Nils Jonsson on September 30, 2004 9:47 AM

"You're as lazy as the ones you critizise."

That's true! Unfortunately I don't have time to retrofit a bunch of PERL code into Movable Type to do something like...

http://www.codinghorror.com/blog/DontDevalueTheAddressBar.htm

.. but you're right. If this was an ASP.NET codebase, I probably would do that.

Jeff Atwood on September 30, 2004 1:02 PM

Supposedly, a good URL with words separated by hyphens can help out a page's ranking in Google. Also, when you're looking at your web site statistics, it's a whole lot easier to identify the articles that people are looking at.

Chris Lundie on October 1, 2004 3:03 PM

Your favorite for 404 errors is to redirect? So I lose the url I typed? So... if I had a typo I'm out of luck? That's not very address bar friendly is it?

Anon on October 5, 2004 6:43 AM

Server.Transfer ; not Response.Redirect. Server.Transfer doesn't send the browser anywhere so the URL is not modified.

Jeff Atwood on October 5, 2004 9:43 PM

I've found adding a GUID helpful to break caches... sometimes it seems to be the only way.

Stormy on November 12, 2004 3:07 PM

Luckily you don't have to. Check out your "Weblog Config" -> "Archive Files" page. My settings:

Individual: daily/<$MTEntryDate format="%Y/%m/%d/"$><$MTEntryTitle dirify="1"$>.html
Daily: daily/<$MTArchiveDate format="%Y/%m/%d/index.html"$>
Monthly: daily/<$MTArchiveDate format="%Y/%m/index.html"$>

That way the title is part of the URL (which is good for Google anyway), and truncating the URL works entirely as expected. Not too terribly difficult.

Richard on March 24, 2005 5:26 PM

The "URL Rewriting" link is broken.

Guy on November 6, 2007 9:44 AM

Supposedly, a good URL with words separated by hyphens can help out a page's ranking in Google. Also, when you're looking at your web site statistics, it's a whole lot easier to identify the articles that people are looking at.
http://stroybalans.ru/

Richard on February 7, 2009 1:56 PM
Content (c) 2009 Jeff Atwood. Logo image used with permission of the author. (c) 1993 Steven C. McConnell. All Rights Reserved.