多站点安装中的子站点在IIS 7中的wp-admin上引发404错误

时间:2014-04-24 作者:tokyovariable

遇到多站点的子站点(新安装的3.9,没有插件或主题)在尝试访问子站点的wp admin部分时抛出404错误的问题。它在IIS7上运行。

  • http://www.mysite.com/subsite/wp-admin -> 抛出404http://www.mysite.com/subsite2/wp-admin -> 抛出404http://www.mysite.com/wp-admin -> 当我们通过登录时,适用于主站点http://www.mysite.com/wp-admin 并导航到子站点,然后尝试注销它也会抛出404。

    正在使用default web.config, 对于重写规则。但所有子站点都在css/js文件上抛出了404个错误。因此,我稍微修改了重写规则,您可以在下面看到。

    <?xml version="1.0" encoding="UTF-8"?>
    <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="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
                        <action type="Redirect" url="{R:1}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="^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)" ignoreCase="false" />
                        <action type="Rewrite" url=“{R:2}” />
                    </rule>
                    <rule name="WordPress Rule 5” stopProcessing="true">
                        <match url="^([_0-9a-zA-Z-]+/)?(wp-comments-post.*)” ignoreCase="false" />
                        <action type="Rewrite" url=“{R:2}” />
                    </rule>
                    <rule name="WordPress Rule 6” stopProcessing="true">
                        <match url="^([_0-9a-zA-Z-]+/)?([_0-9a-zA-Z-]+/)?(.*\\.php)$" ignoreCase="false" />
                        <action type="Rewrite" url="{R:2}" />
                    </rule>
                    <rule name="WordPress Rule 7” stopProcessing="true">
                        <match url="." ignoreCase="false" />
                        <action type="Rewrite" url="index.php" />
                    </rule>
                </rules>
            </rewrite>
        </system.webServer>
    </configuration>
    
    我是否缺少任何其他重写规则或需要更改?因此,子网站在导航到/wp admin页面时不会引发404错误。

1 个回复
最合适的回答,由SO网友:tokyovariable 整理而成

解决了问题。这是生成的“Wordpress规则6”。它给出了两个相同的正则表达式。删除了额外的正则表达式。还必须删除“Wordpress规则5”。重新编号规则,现在一切正常。

这是最新的web.config:

<?xml version="1.0" encoding="UTF-8"?>
<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="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
                    <action type="Redirect" url="{R:1}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="^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)" ignoreCase="false" />
                    <action type="Rewrite" url="{R:2}" />
                </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>

结束

相关推荐

WordPress MultiSite在子目录中,而不是根目录中,并从url中删除基本文件夹

我可能误读了,但我找不到解决以下问题的方法:我想在www 比如说目录www/wp. 然后,我想在多站点网络中添加两个名为foo和bar的博客。当我这样做时,它们最终会显示URL:http://example.com/wp/foohttp://example.com/wp/bar我希望它们位于:http://example.com/foohttp://example.com/bar但是我不想让WP站点在home/root:http://example.com因为我将在那里运行一个不同的应用程序(否则我只需在