Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows IIS7 301重定向-正确的方式_Windows_Wordpress_Redirect_Iis 7_Server - Fatal编程技术网

Windows IIS7 301重定向-正确的方式

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>

我们已经建立了一个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>
这正在工作,站点正在按预期运行。但是当我尝试添加介于标记之间的301列表时,它们似乎不起作用。我没有收到任何错误,只是在转到旧url时没有重定向。服务器管理员已通知我已安装路由模块

我的规则:

<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很遗憾,这也不起作用