IIS URL Rewrite Rule Not Working: Resolving 'HTTP Error 404.4 - Not Found' Issues.

  • Thread starter Thread starter hridaydutta
  • Start date Start date
H

hridaydutta

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.



hridaydutta_0-1724145586617.png



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.



hridaydutta_1-1724145586625.png



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



hridaydutta_2-1724145586628.png



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.



hridaydutta_3-1724145586631.png



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".



hridaydutta_4-1724145586634.png



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.



hridaydutta_5-1724145586638.png

hridaydutta_6-1724145586642.png



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.



hridaydutta_7-1724145586645.png



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

Continue reading...
 
Back
Top