1

我最近在 web.config 中的重写规则之一遇到了问题。它给了我一个 500 错误,但它过去曾经工作过。但是,我最近不得不将它从 .htaccess 更改为 web.config,所以我觉得这可能是问题的一部分,但是即使在更改之后它也可以正常工作,所以我不知道问题是什么?

web.config 现在作为刚刚导入的规则(现在导入后默认),内容如下:

    <?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Imported Rule 1" enabled="false" stopProcessing="true">
                    <match url="^images/([a-zA-Z0-9_-]+\.)(jpg|png|gif)$" ignoreCase="false" />
                    <action type="Rewrite" url="images/old/{R:1}{R:2}" />
                </rule>
                <rule name="Imported Rule 2" enabled="false" stopProcessing="true">
                    <match url="^images/thumbs/([a-zA-Z0-9_-]+\.)(jpg|png|gif)$" ignoreCase="false" />
                    <action type="Rewrite" url="images/old/{R:1}th.{R:2}" />
                </rule>
                <rule name="Imported Rule 3" enabled="false" stopProcessing="true">
                    <match url="^api$" ignoreCase="false" />
                    <action type="Rewrite" url="api.php" />
                </rule>
                <rule name="Imported Rule 4" enabled="false" stopProcessing="true">
                    <match url="^images/(\w*\.)(jpg|png|gif)$" ignoreCase="false" />
                    <action type="Rewrite" url="images/old/{R:1}{R:2}" />
                </rule>
                <rule name="Imported Rule 5" enabled="false" stopProcessing="true">
                    <match url="^images/thumbs/(\w*\.)(jpg|png|gif)$" ignoreCase="false" />
                    <action type="Rewrite" url="images/old/{R:1}th.{R:2}" />
                </rule>
                <rule name="Imported Rule 6" enabled="false" stopProcessing="true">
                    <match url="." ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                        <add input="{URL}" pattern="\.([a-z]{1,4})$" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

我在 web.config 方面不是最好的,所以如果您知道导入后它可能无法正常工作的任何原因,您能帮忙吗?非常感谢!

4

0 回答 0