Configuring Outbound Rewrite Rules

Applies To: Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows Vista

Outbound rewrite rules modify HTTP responses. For example, if your Web site’s navigation structure has changed, you can create an outbound rule that modifies the URLs in your content so that the content of your Web pages points to the correct locations. You can then create inbound rules that redirect client requests that are based on cached locations to the new URLs.

Outbound Rewrite Rules Overview

Outbound rewrite rules define the syntax for rewriting HTTP responses based on a set of parameters that you specify. Conceptually, an outbound rule consists of the following parts:

  1. Pre-condition: Pre-conditions are optional, and are used to test request metadata for specific values before you start to evaluate outbound rules. A pre-condition may consist of several conditional checks for HTTP request metadata, and it may be used to filter out responses that should not be rewritten. For example, a pre-condition can limit the outbound rewrite rule evaluation to process only images or to filter out video files.

  2. Tag filters: Tag filters are used to narrow the search within the response to a set of well-known or custom-defined tags. By using tag filters, only the content of specific tags is matched against the rule pattern, instead of matching the entire HTTP response against the pattern.

  3. Pattern: The rule pattern specifies either the regular expression or a wildcard pattern that will be used for searching within the response content.

  4. Conditions: Conditions are optional, and may be used to specify additional logical comparisons if a URL matched the rule pattern. By using conditions, rewrite rules can test the values of HTTP headers or server variables, or verify that the requested URL corresponds to a file or directory on a physical file system.

  5. Action: The action specifies the behavior for the rewrite rule if the pattern and conditions are met for the rule.

Outbound Rules Execution

Outbound rules are processed differently from inbound rules; inbound rules are executed once on an HTTP request to create a rewritten request URL, whereas outbound rules may be executed several times on an HTTP response as long as the conditions for the rule are being met. Each outbound rule may be filtered for a single HTML tag or for multiple HTML tags. If multiple outbound rules are defined, each rule will be evaluated in the order that it is defined in the configuration files, and each rule where the pattern and conditions are matched will modify the response according to the action that is defined for the rule.

For example, if a single outbound rewrite rule is defined that modifies the anchor tag, (for example, <a href=""></a>), each anchor tag with the HTTP response will be rewritten provided that the pattern and any optional conditions are matched for the rule. If a second outbound rule is added to the collection that filters for anchor tags and image tags, (for example, <a href=""></a> and <img src= "example.jpg">), the rewritten response from the first outbound rule will be rewritten according to the action that is defined for the rule as long as the conditions are met.

See Also


Edit Outbound Rule Page