Simple URL ReWriting/Mapping in IIS7

There’s an easy alternative to other over-complicated solutions on the web if your mappings are simple/static and/or you have a spare grunt to quickly and easily keep them updated without having to write a line of code.

In web.config add:

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>

Under system.web add static mappings like so:

<urlMappings enabled="true">
			<add url="~/default" mappedUrl="index.aspx"/>
			<add url="~/login" mappedUrl="login.aspx"/>
			<add url="~/logout" mappedUrl="logout.aspx"/>
</urlMappings>

Voila.

Of course some scenarios require more complex mappings, but for most non-ecomm/non-web app sites and even blogs this solution would work np, be faster to maintain without requiring assembly publishes and is less error-prone.

Advertisements

About Ronnie Diaz

Ronnie Diaz is an enterprise software engineer responsible for front-end and back-end development for companies in many industries. Heavily involved in cloud development, online retail, e-commerce and electronic ordering, fulfillment and customer relational systems.

Posted on April 6, 2011, in Programming & Development and tagged , , , . Bookmark the permalink. 1 Comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: