IIS URL Rewrite 2.1 skip files that already exist


I have a URL rewrite in my web.config. The rewrite directives are intended to do two things:

  1. If the URL refers to an actual file (such as a css file or image) don't rewrite
  2. If the URL does not refer to an actual file, rewrite to index.php?request={R:1}

Case 2 works perfectly. However, if the requested file exists, I get a generic IIS response indicating an error: HTTP Error 500.50 - URL Rewrite Module Error. - and no other details. The error codes just indicate a generic rewrite module error.

What have I done wrong? This is IIS 10.0

<?xml version="1.0" encoding="UTF-8"?>
                <rule name="Do not rewrite existing files and folders" enabled="true" stopProcessing="true">
                    <match url="^(.*)$" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" />
                    <action type="None" url="{R:0}" appendQueryString="true" logRewrittenUrl="true" />
                <rule name="Framework Parsing" stopProcessing="true">
                    <match url="^(.*)$" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Rewrite" url="index.php?request={R:1}" logRewrittenUrl="true" />
                <remove extension=".php" />
                <remove name="X-Powered-By" />
                <add name="Access-Control-Allow-Origin" value="*" />
                <add name="X-Content-Type-Options" value="nosniff" />
                <add name="X-Xss-Protection" value="1; mode=block" />
                <add name="X-Frame-Options" value="SAMEORIGIN" />
                <add name="Referrer-Policy" value="origin" />
        <!-- staticContent>
            <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="8.00:00:00" setEtag="true" />
        </staticContent -->

This is the error page details:

Module     RewriteModule
Notification       BeginRequest
Handler    StaticFile
Error Code     0x80070005
Requested URL      XXXXXXXXX/css/foundation/foundation.min.css
Physical Path      XXXXXXXXX\public\css\foundation\foundation.min.css
Logon Method       Not yet determined
Logon User     Not yet determined
asked on Stack Overflow Jan 6, 2020 by Wige

1 Answer


I notice that its login method and user is not determined. Please try to enable anonymous authentication for your rewrite rule. And ensure IUSR have permission to access these files.

answered on Stack Overflow Jan 7, 2020 by Jokies Ding

User contributions licensed under CC BY-SA 3.0