我最近遇到了一个问题,我在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中的佼佼者,所以如果你知道为什么导入后它可能无法正常工作,你能帮忙吗?非常感谢!