IIS URL Rewrite 2.1跳过已存在的文件

问题描述 投票:0回答:1

我的web.config中有一个URL重写。重写指令旨在执行以下两项操作:

  1. 如果URL指向实际文件(例如css文件或图像),请勿重写
  2. 如果URL不引用实际文件,则重写为index.php?request = {R:1}

案例2运作良好。但是,如果请求的文件存在,我将收到指示错误的通用IIS响应:HTTP Error 500.50 - URL Rewrite Module Error.-没有其他详细信息。错误代码仅表示一般的重写模块错误。

我做错了什么?这是IIS 10.0

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <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" />
                    </conditions>
                    <action type="None" url="{R:0}" appendQueryString="true" logRewrittenUrl="true" />
                </rule>
                <rule name="Framework Parsing" stopProcessing="true">
                    <match url="^(.*)$" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Rewrite" url="index.php?request={R:1}" logRewrittenUrl="true" />
                </rule>
            </rules>
        </rewrite>
        <caching>
            <profiles>
                <remove extension=".php" />
            </profiles>
        </caching>
        <httpProtocol>
            <customHeaders>
                <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" />
            </customHeaders>
        </httpProtocol>
        <!-- staticContent>
            <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="8.00:00:00" setEtag="true" />
        </staticContent -->
    </system.webServer>
</configuration>

这是错误页面的详细信息:

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
iis url-rewrite-module iis-10
1个回答
0
投票

我注意到它的登录方法和用户尚未确定。请尝试为您的重写规则启用匿名身份验证。并确保IUSR有权访问这些文件。

© www.soinside.com 2019 - 2024. All rights reserved.