使用web.config配置重定向

时间:2019-04-02 18:53:01

标签: wordpress iis web-config multisite

我有一个WP多站点,该站点在底部创建了以下web.config文件(完美运行)。但是,如何为子站点中的各个页面创建301重定向?

<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="WordPress Rule 1" stopProcessing="true">
                    <match url="^index\.php$" ignoreCase="false" />
                    <action type="None" />
                </rule>
                <rule name="WordPress Rule 2" stopProcessing="true">
                    <match url="^wp-admin$" ignoreCase="false" />
                    <action type="Redirect" url="wp-admin/" redirectType="Permanent" />
                </rule>
                <rule name="WordPress Rule 3" stopProcessing="true">
                    <match url="^" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAny">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
                    </conditions>
                    <action type="None" />
                </rule>
                <rule name="WordPress Rule 4" stopProcessing="true">
                    <match url="^(wp-(content|admin|includes).*)" ignoreCase="false" />
                    <action type="Rewrite" url="{R:1}" />
                </rule>
                <rule name="WordPress Rule 5" stopProcessing="true">
                    <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
                    <action type="Rewrite" url="{R:2}" />
                </rule>
                <rule name="WordPress Rule 6" stopProcessing="true">
                    <match url="." ignoreCase="false" />
                    <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
        </rewrite>

    </system.webServer>
</configuration>

我希望页面https://example.com/resources/a-story转到https://example.com/mywork/a-story吗?

我已经阅读了此博客,它说我应该能够生成类似下面的代码片段的内容,它会使多站点崩溃:

https://www.bowlerhat.co.uk/301-redirects-for-seo-from-windows-server-iis

<location path="/resources/a-story">
    <system.webServer>
      <httpRedirect enabled="true" destination="https://foo.com//resources/a-story" httpResponseStatus="Permanent" />
    </system.webServer>
  </location>

0 个答案:

没有答案