我们构建了一个Wordpress站点,客户端服务器正在运行Windows。我个人从未使用过Windows服务器。
我正在努力让301重定向工作。到目前为止,我没有运气。我们设置了 web.config 文件,其中包含以下内容:
<?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>
这是有效的,网站正在按预期运行。但是当我尝试在&lt;之间添加301的列表时规则&gt; 标签似乎不起作用。我没有收到任何错误,只是在转到旧网址时没有重定向。服务器管理员告知我已经安装了路由模块。
我的规则:
<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>
如果斜杠(/)位于网址的末尾,我也更改了匹配的模式:
<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>