The Microsoft URL Rewrite extension in IIS allows you to configure rules for rewriting friendly URLs into back-end URLs.
For more information on using this extension and constructing URL rewrite rules, see the URL Rewrite Module Configuration Reference on Microsoft's support site.
URL rewrite rules are listed in the URL Rewrite window in IIS. You can access this window from the Application Request Routing window by clicking URL Rewrite.
Depending on the bindings already configured, there may be multiple rules available in the URL Rewrite window. For example, there may be a rule for HTTPS traffic (ARR_server_proxy_SSL) and another for HTTP traffic (ARR_server_proxy). If Enable SSL Offloading is selected in the Application Request Routing window, only ARR_server_proxy is available. You can also create additional rules if needed to rewrite URLs to multiple APIs or servers.
You can edit a rule by selecting it and clicking Edit to display the Edit Inbound Rule window. Edit each rule with the following settings:
Option |
Description |
---|---|
Requested URL |
Set to Matches the Pattern. |
Using |
Set to Wildcards. |
Pattern |
Enter the wildcard rule pattern used to identify and match strings in friendly URLs. Note that this matching pattern does not include the machine or server name, but rather looks at the rest of the URL after the machine name. Configuration of this pattern depends on which segments of the friendly URL you want to match and include in the rewrite URL. For example:
Tip:
Click Test pattern to use the pattern tester. This can help identify which segments that each back-reference will include in the rewrite URL. |
Conditions |
Do not make any changes to this section. |
Server Variable |
Do not make any changes to this section. |
Action type |
Set to Rewrite. |
Rewrite URL |
Enter the substitution URL to use when rewriting the friendly URL. The Rewrite URL can include back-references to construct the substitution URL by referencing the wildcard rule used in the Pattern field. Back-references can include:
Note:
Back-references only include the URL segments matched by the Pattern; they do not include the machine or server name. For example, appending a back-reference to a rewrite URL of http://hostname/{R:0} instructs the proxy to accept all characters in the friendly URL after the machine or server name, and include those characters at the end of the substitution URL. |
Append query string |
Ensure that this option is selected. |
URL rewrite rules determine the behavior of configured URLs. Rules can be configured so only specific virtual directories or routes are exposed, based on the needs of the solution and security considerations in the environment. For example, a website named http://addr.friendly.net/ with a rewrite URL of http://serv001.backend.net/{R:0} will forward all requests that begin with http://addr.friendly.net/, so both http://addr.friendly.net/service.asmx and http://addr.friendly.net/internal/api/documents/ would be forwarded to the server, while http://www.friendly.net/ would not.