【问题标题】:IIS URL Rewrite 2.1 skip files that already existIIS URL Rewrite 2.1 跳过已经存在的文件
【发布时间】:2020-04-24 06:46:16
【问题描述】:

我的 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】:

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

    【讨论】:

      猜你喜欢
      • 2012-03-13
      • 2019-07-10
      • 1970-01-01
      • 2020-05-03
      • 2011-06-24
      • 2021-08-15
      • 2013-01-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多