Make URL rewriting in IIS 7 work like in IIS 6

May 18, 2009 · Follow on Twitter and Mastodon archive

I’ve had a lot of problems with getting URL rewriting to work with Windows Vista and IIS 7. Compared to IIS 6, virtual paths in IIS 7 don’t allow extensions like .js, .css, which is problematic if you have shared files in virtual paths.

This problem is discussed in this excellent article. Although it may seem long, it has fixes that only takes a minute or so to get in place:

  • Check out web.config (non-exclusive) if you have it under version control.
  • Open IIS and select the correct application pool (or create one if needed).
  • Switch from Managed Pipeline Mode to Classic under Basic Settings.
  • Select the correct web site and open the “HandlerMappings” section.
  • Open the StaticFile handler.
  • Change its Request Path to . and its mapping from “File or Folder” to “File”.
  • Click “Add Script Path” and add an aspnet_isapi handler.
  • Change its Request Path to * and give it a name of your choice.
  • Finally, click “View Ordered List” and move the ISAPI handler to the very bottom.

After this, your web application will, hopefully, behave correctly.

Make sure that you have a dedicated application pool for the web application when you perform these changes, otherwise they will affect the default application pool, which is not recommended.

Note that you shouldn’t check in any changes that are made to web.config, since it will add IIS 7 specific parameters. If the file changes, simply reset the changes and repeat the commands above.

Discussions

Please share any ideas, feedback or comments you may have in the Disqus section below, or by replying on Twitter or Mastodon..

Follow for more

If you found this interesting, follow the Twitter and Mastodon accounts for more content like this, and to be notified when new content is published.