IIS URL Rewrite Rule Not Working: Resolving ‘HTTP Error 404.4 – Not Found’ Issues.
Issue
Most of you have encountered situations where you have used IIS URL Rewrite to redirect traffic from one site to another. But in some cases, rewrite rules fail to work as expected and returns ‘HTTP Error 404.4 – Not Found’. The 404.4 status code means no handler configured. Which means the file name extension of the requested URL doesn’t have a handler that is configured to process the request on the Web server.
For example you have two sites hosted in IIS. Site1 bind with port 81 and Site2 bind with port 82. The requirement is to rewrite all the request coming to Site1 (port:81) should rewrite to Site2 (port:82). The below rule is configured –
<system.webServer>
<rewrite>
<rules>
<rule name=”RewriteToPort81″ stopProcessing=”true”>
<match url=”^.*$” />
<action type=”Rewrite” url=”http://localhost:82/{R:0}” appendQueryString=”true” />
</rule>
</rules>
</rewrite>
</system.webServer>
Solution
First you need to check if the correct module is installed in IIS. To check this go to IIS Manager and open the Modules.
Within the Modules check if the correct URL Rewrite module is installed. You can get the latest IIS URL Rewrite module from this link
URL Rewrite : The Official Microsoft IIS Site
If the correct module is installed as highlighted above, the next thing you check the Failed Request Tracing logs for the request. And verify if the correct rule is invoked and it updates the URL to new one.
Here in this case you can see “RewriteToPort82” rule is invoked and it changed the request URL to http://loalhost:82/. Also verify if the HttpStatus=”404″ and HttpSubStatus=”4″.
To remediate the issue, go to IIS Manager, open Application Request Routing Cache module and open Server Proxy Settings form the right-hand Actions pane.
Within the Server Proxy Settings you will find an option to enable proxy. Check the Enable proxy checkbox and click apply form the right-hand Actions pane as pointed in the below picture.
After this you need to restart IIS. This should resolve the URL rewrite issue. To know more about URL rewrite in IIS you can follow this article – Using the URL Rewrite Module | Microsoft Learn
Microsoft Tech Community – Latest Blogs –Read More