O'Reilly logo

Professional Microsoft IIS 8 by Benjamin Perkins, Dennis Glendenning, Scott Forsyth, Jeff Cochran, Kenneth Schaefer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Outbound Rules

Version 2.0 of URL Rewrite introduced support for outbound rules. These rules can change not only the headers but also the entire page body as it leaves the server before it reaches the end user.

This is useful when you can't easily make code changes, or if you are using a third-party application that you can't control. Using outbound rules, you can make edits such as changing URLs or other strings within the body of the webpage, or updating the URL in a client-side redirect.

Outbound rules can rewrite either the body of the response or a server variable.

For response rewrites, URL Rewrite will parse the body of the page and make changes as needed. Content filters can narrow the focus to just certain tags—for example, a form, a, or img tag for URL edits.

The other type of outbound rule will change server variables (for example, X-PoweredBy), or server variables can be replaced with a setting of your choice.

Outbound Rules versus Inbound Rules

Fundamentally, outbound rules are the same as inbound rules, but the structure of the rules is surprisingly different, so there are some new concepts to note.

The first thing to be mindful of is that outbound rewrite rules will parse the entire body of the page, which, as you can guess, can be CPU-intensive. There are filters to make this more efficient, but it's still important that you perform the full parsing only when you have to. This is where preconditions come in.

Preconditions are specific to outbound rules and enable ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required