Creating User-Friendly URLs With IIS

Something I've seen and always wanted to emulate are URLs like this:


As you can tell just from looking at this URL - it's a question on StackOverflow.com about whether you can pass array to E4X. And you can tell all that simply by looking at the URL!

Not only is this good for the user (perhaps) but it's good for Google and SEO of a site in general.

But how do you do it? I'd always assumed (naively) that you'd have to:

  1. Store the URL-safe version of the question in the database.
  2. Ensure this URL-ready version of the title was unique.

Turns out neither of those are true. The only part of the URL the backend code cares about is the question ID (1491939).

How To Do It:

I'll cover IIS as that's what I've been using just recently. First open IIS manager app and find the URL Rewrite plugin for your website:


In there choose Add Rule and then "User-friendly URL":


In the next dialog you enter the URL of the ASPX page as the server expects it and then the Rule works out the user-friendly for it, as you can see below, using the Stackoverflow example:


You also get the option to have IIS rewrite out-going HTML to make sure all internal links point to this new friendly format. I left this un-ticked though and just made sure I stuck to the new convention when building my pages.

As you can see it uses Regular Expression to re-write the URLs. Notice it's sending the title part of the URL to the server as a parameter. It doesn't need to though and this parameter isn't referred to by the code.

That's how simple it is though. I can't believe it didn't dawn on me that it would be this straight-forward. Doh!

Here are some example of it in use with a new site I'm working on (for myself).



Is it just me that gets a warm fuzzy feeling inside from being able to do stuff like this. Must be a geek thing.


    • avatar
    • Jon
    • Tue 4 May 2010 04:36 AM

    Isn't part of creating User Friendly URLs that they can be easily remembered by an end user? Having a number in them defeats the object slightly. Wouldn't something like /region/the_peak_district be better?

    Not sure how easy it would be to create thou. Just my thoughts.

      • avatar
      • Jake Howlett
      • Tue 4 May 2010 04:45 AM

      You're probably right Jon. Notice the getout word in brackets from above:

      "Not only is this good for the user (perhaps) "

      I say perhaps as I'm not actually sure how URLs are seen or used by the average web user. Do they pay much attention? I don't know. Do they ever remember them or type them in - or do most people just use Google to find *everything*. I know my dear wife uses google (her browser homepage) to search for www.boots.com and then clicks the first result to go there. I told her about the address bar once but it was lost on her.

      What the site could do is have a way to intercept URLs like:


      And 301 redirect them to the right URL. One for the list.

      Show the rest of this thread

    • avatar
    • Lance Jurgensen
    • Tue 4 May 2010 08:03 AM

    Keep up the IIS and .aspx posts Jake! Unfortunately we have just decided to jump off the domino ship and are boarding the Exchange/Sharepoint/.net ship now!

      • avatar
      • Jake Howlett
      • Tue 4 May 2010 08:42 AM

      It's probably unavoidable that there'll be more ASP.NET talk coming up on here.

      I've always tended to talk about whatever it is I'm mainly doing at the time and - if things go to "plan" - ASP.NET will be playing a large part in my workload for the coming year(s).

      • avatar
      • Palmi
      • Tue 4 May 2010 06:31 PM

      Am Sorry Lence :)

  1. You can achieve the same thing by using the Routing functionality included from .NET 3.5SP1 onwards. Although it was originally intended for use with MVC it works nicely with traditional webforms apps too. The advantage with that approach is no IIS configuration changes are needed, i.e. handy for shared webhosts.

    • avatar
    • Joey
    • Wed 5 May 2010 06:07 AM

    Thanks Jake, interesting article!

  2. On (somewhat) of a related note, there are also services such as:


    • avatar
    • ianb
    • Wed 5 May 2010 04:09 PM

    You're right to question what normal users see/use in relation to urls.

    Pretty much all my users do not know what the address bar is. If I ask them to type an address in (specifically stating where, I might add), the response is usually "OK, now I've got a long list of them, which do I open" (can you see, what they did :-) )

    The other day I watched someone open up the browser, which happened to default to bing, search for google and then search for the item they wanted......

    I think as long as your main site links are memorable (so, the homepage url and pretty much then the categories or channels) then anything else is just tidywork.

Your Comments


About This Page

Written by Jake Howlett on Tue 4 May 2010

Share This Page

# ( ) '


The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social

About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content