What's the best way to get a nice clean URL structure like stack overflow has?

Do I need to use IIS for this? Or is there a way I can do it with some sort of mapping file in asp .net?

The site I want this for has hundreds of pages, and is already deployed.
I would like a method that requires the least amount of changes possible.


  • I do not want suggestions on how to make the URLs friendly
  • I do want suggestions on how to best manage these friendly URLs and how to create the mappings.

I basically want to have each path that ends with aspx have no aspx extension and instead look like it is a folder with an index.aspx inside of it.


EDIT: I'm running IIS 6.0

+3  A: 

from what I understand, you are looking for a tool to help you with mappings.

If that is the case, you can try the "user friendly url - rule template" feature of url rewrite module (iis7)

Rule templates are used to provide a simple way of creating one or more rewrite rules for a certain scenario. URL rewriter module includes several rule templates for some common usage scenarios. In addition to that URL rewrite module UI provides a framework for plugging in custom rule templates.

+1  A: 

Stackoverflow uses System.Web.Routing. It's originally from MVC but usable in any app. I'm not sure how easy or hard it would be to retrofit routing into an existing app though.

Ben Robbins
+1  A: 

I have been using a tool called Ionic Rewriter

It will use regular expression to rewrite your extensionless URLs to physical URLs for processing. The user only sees the extensionless one however the webserver sees the .aspx etc one.

It seems to work extremely well and is very easy to configure.

+2  A: 

Perhaps urlMappings could work for you:

  <urlMappings enabled="true">
    <add url="~/test/" mappedUrl="~/test.aspx"/>

To make it work on IIS6 you to enable wildcard mappings.

Cristian Libardo

i dont know if IIS6.0 supports it or not, but i use web.sitemap, i add an attribute with every node that equals the pretty name i want, then with Application_onBegin I map the pretty url of the request to the one in the sitemap...

you asked for the best way, but I dont think there is one "best" way, Ive seen people feed the pretty names from an xml file, others rely on IIS7.0 rewrite feature


This is how I do IIS6 rewriting (URL Rewriting Made Easy)

The problem with this is that you still have the .aspx extension unless you do Wildcard mapping from within IIS.

If you ever get a chance to upgrade to IIS7, you can do it all with a free dll and from within your web.config (no programming, no IIS configuration) Extensionless URL's, IIS7, and URLRewritingNet.