Web.config打破了子目录MultiSite的主题

时间:2014-06-16 作者:Simon Vacker

我们正在将单个wordpress站点转换为子目录网络,但找不到任何web。正确工作的配置。一旦我们更改了单站点web,我们就永远无法让主题发挥作用,即使是在根(/)站点上。为多站点配置,它会中断。

我已经搜索了几个小时,找到了几个人们找到网站的主题。配置对我们有效,但没有一个对我们有效,主题总是被打破。

我们需要的设置如下:

http://www.domain.com/ (主站点)http://www.domain.com/en/ (网站英文版)

我确实在我自己的Apache服务器上实现了一定程度的功能,但它尝试在/en/media/中查找媒体,而实际上应该是/media/。然而,我们使用的主机显然使用IIS。

Here is one web.config I\'ve tried which lets me access the dashboard for all sites and everything seems to work except for the theme:

<?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-]+/)?files/(.+)" ignoreCase="false" />
                <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
            </rule>
            <rule name="WordPress Rule 3" 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 4" 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 5" 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 6" stopProcessing="true">
                <match url="^([_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>
这是网站。按照Wordpress网络设置页面的建议进行配置,此页面将生成/en/site dashboard 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:1}" />
            </rule>
            <rule name="WordPress Rule 5" 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 6" stopProcessing="true">
                <match url="." ignoreCase="false" />
                <action type="Rewrite" url="index.php" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>
</configuration>
两者都不起作用。非常感谢您的帮助。

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

我向我们的托管提供商寻求帮助,他们修改了第一个网站。配置工作。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
<!--    <security>
      <authentication>
        <basicAuthentication enabled="false"/>
        <anonymousAuthentication enabled="false"/>
      </authentication>
    </security>-->
    <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-]+/)?files/(.+)" ignoreCase="false" />
<action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
</rule>
<rule name="WordPress Rule 3" 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 4" 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" />
<add input="{URL}" pattern="([a-zA-Z0-9\\./_-]+)\\.axd" />
</conditions>
 <action type="None" />
 </rule>
<rule name="WordPress Rule 5" stopProcessing="true">
<match url="^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*)" ignoreCase="false" />
<action type="Rewrite" url="{R:1}" />
</rule>
<rule name="WordPress Rule 6" stopProcessing="true">
<match url="^([_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>

结束