Hi,
I have setup a new instance of IIS (actually in the form of an Azure Web App) with the following URL rewrite rule in web.config:
<rewrite><rules><rule name="StaticContent"><action type="Rewrite" url="public{REQUEST_URI}"/></rule></rules></rewrite>
The premise is that all requests to the site for static files are redirected to a 'public' subfolder and served from there. This seems to work and the appropriate file is served properly.
However, enabling Detailed Error output for the Web App (for another reason) has revealed a 404 error that appears to occur for every static file request. The error file output is an 404 error page, and I'm not familiar enough with the internal workings of IIS to know why this is created and yet the request still actually succeeds. I've attached an image of the error page, but notice that the path is "/scripts/..." and "wwwroot\scripts\.." without the 'public' prefix that should have been written in.
I performed a failed request trace and found that an error was occurring at FILE_CACHE_ACCESS_START which seems like it might have been the cause. I've attached an image of this section.
Note that the file path is also missing the 'public' prefix, even though the rewrite module ran successfully earlier on in the trace.
--
At this point in typing this post, I discovered that after the rewrite module begins, it creates a child request so that the module order is as follows in the trace:
NOTIFY_MODULE_START: RewriteModule
- test rewrite rules -
GENERAL_CHILD_REQUEST_START (using RequestURL with the rewritten url)
- perform full request -
GENERAL_CHILD_REQUEST_END
NOTIFY_MODULE_END: RewriteModule
- continue with the rest of the initial request using the incorrect un-rewritten URL -
And this last part is where the error occurs in FILE_CACHE_ACCESS_START.
So my final question is now: How do we prevent this initial request for the un-rewritten URL?