Rewrite Outbound URLs with IIS 7 and URL Rewrite Module 2.0
The URL Rewrite Module was originally introduced to map incoming, user-friendly URLs to pages written with ASP.NET or PHP. With version 2, the other side is addressed. URLs automatically generated by applications can rewritten before they hit the user’s browser.
Outbound rules consist of several parts:
- Tag Filters allow you to look at only specific types of tags like anchors (a) or images (img).
- Patterns are based on either wildcard matches or full regular expressions. The regular expression engine is supposed to be Perl compatible and ECMAScript standard compliant. However, without knowing the specific engine used, there is bound to be unforeseen quirks. Wild cards, while easier to write, can only be used in conjunction with tag filters.
- Conditional checks based on the pattern matches can further restrict the rule.
- The actual rewriting, referred to as the “rule action”, can be based on a combination of pattern matches and the server variables.
Speaking of which, both server variables and request headers can also be rewritten using this module. Pattern matching and conditional checks can be applied to rules that alter these.
In order to assist in debugging, logging of rewritten URLs is now possible by editing a registry setting.
You can find out more in the URL Rewrite Module 2.0 Configuration Reference.
So, the big news is...