Return 404.4 Not Found when URL Rewrite


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.

i

URL_CHANGED

OldUrl=”/81″, NewUrl=”http://localhost:81″

22.

i

URL_REWRITE_END

RequestURL=http://localhost:81

 

But it fails with 404.4 in IIS Web Core.

156.

r

MODULE_SET_RESPONSE_ERROR_STATUS
Warning

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

Comments (9)

  1. Mindaugas says:

    That did the trick. Thanks! I was trying to redirect to *.do page.

  2. SK says:

    This resolved my problem.

    Thank you very much!

  3. Radu says:

    Thanks a lot, Anik! ARR install & proxy enable works 🙂

  4. Chris says:

    Thanks so damn much, IIS is such a piece to find info for and this finally resolved my issue.

  5. MasterMind says:

    This was very helpful.

    Thank you very much!

  6. Max says:

    Thanks a lot! Very very helpful 🙂

  7. Max says:

    Very very helpful. Thank you!

  8. Pablo says:

    Thanks!!

Skip to main content