WordPress 301在IIS上重定向

WordPress 301在IIS上重定向,wordpress,url-redirection,http-status-code-301,iis-8.5,Wordpress,Url Redirection,Http Status Code 301,Iis 8.5,在部署了一个新网站之后,我真的很难让301重定向在我们的服务器上工作。我尝试过的每件事要么导致500个错误,要么就是根本不起作用 下面是从我的web.config文件中摘录的重写部分 <rewrite> <rules> <rule name="wordpress" stopProcessing="true"> <match url=".*" /> <conditions

在部署了一个新网站之后,我真的很难让301重定向在我们的服务器上工作。我尝试过的每件事要么导致500个错误,要么就是根本不起作用

下面是从我的
web.config
文件中摘录的重写部分

<rewrite>
    <rules>
        <rule name="wordpress" stopProcessing="true">
            <match url=".*" />
            <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            </conditions>
            <action type="Rewrite" url="index.php" />
        </rule>
        <rule name="301 Redirect 1" stopProcessing="true">
            <match url="^join$" />
            <action type="Redirect" url="careers" redirectType="Permanent" />
        </rule>
    </rules>
</rewrite>

但我只是在访问时得到一个404

我已经检查并安装并启用了URL重写模块


我做错了什么?

将301重定向作为第一条规则移动到wordpress规则之前

<rewrite>
    <rules>
        <rule name="301 Redirect 1" stopProcessing="true">
            <match url="^join$" />
            <action type="Redirect" url="careers" redirectType="Permanent" />
        </rule>
        <rule name="wordpress" stopProcessing="true">
            <match url=".*" />
            <conditions logicalGrouping="MatchAll">
                <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>

替换web.config文件中的代码并用以下代码更新

 <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Main Rule" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<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>
</system.webServer>
</configuration>


这似乎有效,您能否解释原因?您的“*”匹配也会加入,并且stopProcessing在第一次尝试时停止了规则匹配,然后您总是在旧设置中点击第一条规则。此答案无法解决主要问题。事实上,这是一个倒退,因为它忽略了包含失败的重定向。