Windows IIS7 301重定向-正确的方式
我们已经建立了一个Wordpress站点,客户端服务器正在运行Windows。我个人从未使用过Windows服务器 我正在努力使301重定向正常工作。到目前为止,我运气不好。我们使用以下内容设置了web.config文件:Windows IIS7 301重定向-正确的方式,windows,wordpress,redirect,iis-7,server,Windows,Wordpress,Redirect,Iis 7,Server,我们已经建立了一个Wordpress站点,客户端服务器正在运行Windows。我个人从未使用过Windows服务器 我正在努力使301重定向正常工作。到目前为止,我运气不好。我们使用以下内容设置了web.config文件: <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <defaultDocument>
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="Default.htm" />
<add value="Default.asp" />
<add value="index.htm" />
<add value="index.html" />
<add value="iisstart.htm" />
<add value="default.aspx" />
<add value="index.php" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="WordPress Rule" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
<staticContent>
<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
<mimeMap fileExtension=".ogv" mimeType="video/ogv" />
<mimeMap fileExtension=".webm" mimeType="video/webm" />
</staticContent>
</system.webServer>
</configuration>
这正在工作,站点正在按预期运行。但是当我尝试添加介于<rule name="301 Redirect 1" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAny">
<add input="{URL}" pattern="/insight/$" />
</conditions>
<action type="Redirect" appendQueryString="false" url="/services/insight/" redirectType="Permanent" />
</rule>
另一个:
<rule name="301 Redirect 2" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAny">
<add input="{URL}" pattern="/contact-us/$" />
</conditions>
<action type="Redirect" appendQueryString="false" url="/contact/" redirectType="Permanent" />
</rule>
有人能提供建议吗
---编辑---
我也尝试过:
<rule name="301 Redirect 2" stopProcessing="true">
<match url=".*" ignoreCase="true" />
<conditions logicalGrouping="MatchAny">
<add input="{URL}" pattern="\/contact-us\/$" />
</conditions>
<action type="Redirect" appendQueryString="false" url="/contact/" redirectType="Permanent" />
</rule>
我还更改了模式,以匹配url末尾是否有斜杠/的情况:
<rule name="301 Redirect 2" stopProcessing="true">
<match url=".*" ignoreCase="true" />
<conditions logicalGrouping="MatchAny">
<add input="{URL}" pattern="\/contact-us((\/\w+)+|\/?)$" />
</conditions>
<action type="Redirect" appendQueryString="false" url="/contact/" redirectType="Permanent" />
</rule>
请删除前导/输入模式,然后重试。@LexLi很遗憾,这也不起作用