Although you can use UrlRewriter.NET without making any changes to your IIS configuration, you will have a few limitations in the sorts of friendly URLs you can use. In particular, the URL must be mapped to the ASP.NET runtime in order for UrlRewriter.NET to rewrite it. To get the full power of UrlRewriter.NET, configure IIS 6.0 to map all requests to the ASP.NET runtime.

Configuring IIS 6.0 on Windows Server 2003 to enable UrlRewriter.NET is easy because IIS 6.0 supports wildcard application mappings. This setting enables IIS to map all unrecognised application requests to (in our instance) the ASP.NET runtime. To enable this wildcard mapping which will enable the UrlRewriter.NET component to work, follow these simple steps on each web server where UrlRewriter.NET will be running (even you developer desktop):

  1. Open Internet Information Services (IIS) Manager

    click to expand
  2. Right-click on the website where you want to configure UrlRewriter.NET and select Properties.

    click to expand
  3. Click on the Home Directory tab.

    click to expand
  4. Click the Configuration button.

    click to expand
  5. Select the .asax application extension and click Edit…

    click to expand
  6. Copy the Executable path (…\aspnet_isapi.dll) to the clipboard and click Cancel.

    click to expand
  7. Click Insert…

    click to expand
  8. Paste the Executable path (…\aspnet_isapi.dll) from the clipboard, untick Verify that file exists.

    click to expand
  9. Click OK to close the Add/Edit Application Extension Mapping dialog

    click to expand
  10. Click OK to close the Application Configuration dialog.

    click to expand
  11. Click OK to close the Properties dialog.
  12. That’s it! The server is configured to allow UrlRewriter.NET to work its magic.

There are a few things to note with this configuration:

  1. All web requests will now be sent through the ASP.NET runtime.
  2. Default documents specified in IIS will stop working. You will need to add a rule to your rewrite rules to support the default documents you want, as in:
    <rewrite url=”^(.*)/(\?.+)?$” to=”$1/default.aspx$2″ />
  3. Requests for images, stylesheets, favicon.ico and everything else will be processed by .NET. You may want to add rules to cater for these. This is also a bonus, in that you can now restructure your website assets and put in place the correct rewriting rules to ensure these can be found in the new location.