I have a simple ASP website running on IIS on port 81 on a Windows 11 PC with the latest ASP.NET Core Runtime 8.0.14
hosting bundle installed and the website is compiled for .NET 8
.
Accessing the website through localhost:81
works just fine.
I have installed URL Rewrite
and Application Request Routing
(and enabled the proxy) and setup a simple rule to map any incoming requests to localhost/mysite
to localhost:81
:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule" stopProcessing="true">
<match url="^mysite/(.*)$" />
<action type="Rewrite" url="http://localhost:81/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
When accessing the website through localhost/mysite
I get a 404:
I have used this URL Rewrite rule before and it normally works but the error message says that the Physical Path
is C:\inetpub\wwwroot\mysite\
but the real physical path is C:\Websites\mysite
.
I have tried setting up Failed Request Tracing
but I don't get any output in C:\inetpub\logs\FailedReqLogFiles
:
<tracing>
<traceFailedRequests>
<add path="*">
<traceAreas>
<add provider="ASP" verbosity="Verbose" />
<add provider="ISAPI Extension" verbosity="Verbose" />
<add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,FastCGI,WebSocket" verbosity="Verbose" />
</traceAreas>
<failureDefinitions statusCodes="100-999" />
</add>
</traceFailedRequests>
</tracing>
If I should be so lucky that someone with deeper knowledge of why this happens should read this post I will definitely welcome some guiding!
Try to set the url rewrite rule pattern as shown below:
^mysite/?(.*)
OR
^mysite(.*)
and make sure you have added the rule to the iis default website