IIS web.config条件

时间:2018-08-03 18:07:31

标签: iis web-config

我有一个具有以下web.config设置的Windows服务器。 问题是该行:<remove fileExtension=".json" />

如何重写它以允许.json目录中的videos个文件?

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <defaultDocument>
            <files>
                <clear />
                <add value="index.php" />
                <add value="index.html" />
            </files>
        </defaultDocument>
        <rewrite>
            <rules>
                <rule name="Imported Rule 1" stopProcessing="false">
                    <match url="^(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{R:1}" pattern="^(index\.php|videos)" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="/index.php/{R:1}" />
                </rule>
            </rules>
        </rewrite>
        <httpErrors errorMode="Detailed" />
        <security>
            <requestFiltering>
                <requestLimits maxAllowedContentLength="123456789" />
            </requestFiltering>
        </security>
        <staticContent>
            <remove fileExtension=".json" /><!-- NEED CONDITION -->
            <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
        </staticContent>
    </system.webServer>
</configuration>

1 个答案:

答案 0 :(得分:0)

从评论中复制。

IIS配置允许多种方式为您的案例设置设置。可以在this article中找到更多详细信息。

您可以在此<location>文件中为video添加web.config标签,然后再添加.json

或者,您也可以在视频文件夹中直接放置一个专用web.config