URL Rewrite module can redirect a URL to any internal (on the same site) or external URLs (on a separate site).
http://www.iis.net/download/urlrewrite
However, URLRewrite rewrite rule to external site doesn’t work. You can only rewrite the URL in the same site and same application pool.
For example, let’s set following rule to rewrite original Requested URL: http://localhost/81 to http://localhost:81
<rewrite>
<globalRules>
<rule name="URLTest">
<match url="([0-9]+)" />
<action type="Rewrite" url="http://localhost:{R:1}" appendQueryString="true" />
</rule>
</globalRules>
</rewrite>
Test http://localhost/81 and return HTTP Error 404.4- Not Found
The resource you are looking for does not have a handler associated with it.
Check FREB Log, it shows RewriteModule execute successfully
14.
PRE_BEGIN_REQUEST_START
ModuleName="RewriteModule"
15.
i
URL_REWRITE_START
RequestURL="/81", Scope="Global", Type="Inbound"
16.
RULE_EVALUATION_START
RuleName="URLTest", RequestURL="81", QueryString="", PatternSyntax="Regex", StopProcessing="false", RelativePath="/"
17.
PATTERN_MATCH
Pattern="([0-9]+)", Input="81", Negate="false", Matched="true"
18.
REWRITE_ACTION
Substitution="http://localhost:{R:1}", RewriteURL="http://localhost:81", AppendQueryString="true", LogRewrittenURL="false"
19.
RULE_EVALUATION_END
RuleName="URLTest", RequestURL="http://localhost:81", QueryString="", StopProcessing="false", Succeeded="true"
20.
GENERAL_SET_REQUEST_HEADER
HeaderName="X-Original-URL", HeaderValue="/81", Replace="true"
21.
URL_CHANGED
OldUrl="/81", NewUrl="http://localhost:81"
22.
URL_REWRITE_END
RequestURL=http://localhost:81
But it fails with 404.4 in IIS Web Core.
156.
r
MODULE_SET_RESPONSE_ERROR_STATUSWarning
ModuleName="IIS Web Core", Notification="MAP_REQUEST_HANDLER", HttpStatus="404", HttpReason="Not Found", HttpSubStatus="4", ErrorCode="The filename, directory name, or volume label syntax is incorrect.
(0x8007007b)", ConfigExceptionInfo=""
Solution
======
You need to install Application Request Routing and enable Proxy, then it will work with URL rewriting to remote servers (regardless where or what they are) since the Routing will take care of that.
http://www.iis.net/download/ApplicationRequestRouting
Enjoy!
Anik
That did the trick. Thanks! I was trying to redirect to *.do page.