如何使用子目录在Azure上设置Wordpress多站点 [英] How to set-up Wordpress Multi-sites on Azure using sub-directories

查看:47
本文介绍了如何使用子目录在Azure上设置Wordpress多站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关在Windows Azure上使用子目录运行的Wordpress Multisite的问题:它可以工作吗?你如何做到的?.

我已经从Azure库安装了Wordpress(4.2.2),更新了wp.config.php和web.config文件以启用和安装多站点,但是结果是半个可行的解决方案:安装了多站点,并且我可以创建和删除新网站,但是新网站没有CSS样式(404错误),并且我无法访问其管理信息中心(404:您要查找的资源已被删除,名称已更改,或者暂时不可用.

I've installed Wordpress(4.2.2) from the Azure Gallery, updated the wp.config.php and web.config files to enable and install Multisites, but the result is a half working solution: Multi-sites is installed, and I can create and delete new sites, but the new sites have no css styling (404 errors) and I can't access their admin dashboards (404: The resource you are looking for has been removed, had its name changed, or is temporarily unavailable).

例如,基础网站:

http://mywordpressmultisite.azurewebsites.net

正常工作.但是多站点:

works fine. But the multi-sites:

http://mywordpressmultisite.azurewebsites.net/site2/ http://mywordpressmultisite.azurewebsites.net/site3/

显示一个无样式的CSS网站,但是由于我没有管理员访问权限,因此我无法对其做任何事情;可能是路由错误.

Display an unstyled css website, but I can't really do anything with them since I have no admin access; a routing error perhaps.

更多详细信息

我已按照以下方法撰写文章: https://azure.microsoft.com/en-gb/documentation/articles/web-sites-php-convert-wordpress-multisite/,以便在Azure上设置Wordpress Multisite以便目录.我没有结束标题为添加自定义域"的部分,因为我不想这样做(无论如何).

I've followed this how to article: https://azure.microsoft.com/en-gb/documentation/articles/web-sites-php-convert-wordpress-multisite/, to set-up Wordpress Multisite on Azure for sub-directories. I haven't followed on past the section entitled Add Custom Domains because I don't want to do that (yet, anyway).

我的web.config文件是:

My web.config file is:

<?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>

我的wp-config.php是:

My wp-config.php is:

define( 'WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'mywordpressmultisite.azurewebsites.net');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

我尝试过的事情

  • 同时使用免费和共享托管解决方案.
  • 检查固定链接在标准wordpress和基础No1网站上是否有效(因此mywordpressmultisite.azurewebsites.net/helloworld可以正常运行).
  • 清理数据库并重新开始整个过程​​.
  • 更改文件权限以允许读取,写入和执行;以防万一.

调试

我已经在Windows Azure上配置了WebApp,以记录所有可能的记录,但它不会吐出任何东西.我找不到php_error.log或其他日志文件中的任何内容.我已经按如下方式配置了wordpress wp-config.php,但是仍然无法产生任何东西:

I've configured the WebApp on Windows Azure to log everything possible but it's not spitting anything out. There's nothing in the php_error.log or other log files that I can find. I've configured wordpress wp-config.php as follows, but again nothing is being produced that I can find:

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', true);
@ini_set('display_errors', 0);

我在哪里我对如何完成这项工作的想法一无所知,并且开始怀疑它是否确实适用于Azure的子目录?我在网上看到了其他有关此问题的参考,但没有解决方案.

Where I am I'm flat out of ideas on how to get this work, and I'm beginning to wonder whether it actually does work on Azure for sub-directories? I have seen other references to this issue on the web but no solutions.

推荐答案

此IIS上的stackoverflow问题具有答案:

This stackoverflow question on IIS has the answer:

在管理面板上在WordPress子域中的子目录多站点上获取404错误

它为web.config提供了此XML

It gives this XML for the 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-]+/)?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>

我已将此文件上传到Azure,并且可以使用.现在可以访问主题和仪表板.

I've uploaded this to Azure and it works. Theme's and dashboard are now accessible.

不确定原始web.config中的错误在哪里,我想知道这一点,因为Wordpress似乎提供了错误的web.config xml,但是

Not sure where the error is in the original web.config, which I would like to know as Wordpress seems to be providing the wrong web.config xml, but http://www.iis.net/learn/extensions/url-rewrite-module/url-rewrite-module-configuration-reference may help work it out.

这些IIS web.config路由重写规则似乎基于此处提供的Apache .htaccess和Mod重写规则: https://codex.wordpress.org/Multisite_Network_Administration

It would seem these IIS web.config routing rewrite rules are based on the Apache .htaccess and Mod rewrite rules given here: https://codex.wordpress.org/Multisite_Network_Administration

我在上面找到并使用的web.config确实有效,它似乎是源于.htaccess文件的,该文件的目标是<的Wordpress版本.3.5.

The web.config which I found and used above, which does work, would appear to be derived from a .htaccess file targetting Wordpress versions of < 3.5.

在Mulisite安装中,作为Wordpress提供的原始版本,该文件基于针对Wordpress 3.5+的.htaccess文件.

Where as the original version provided by Wordpress, as part of the Mulisite install, is based on the .htaccess files targeting Wordpress 3.5+.

从工作的web.config中引用规则,将其与不起作用的规则相关联:

Referencing rules from the working web.config in relation against those in the one which doesn't work:

  • 规则1:完全相同.
  • 规则2:这是一条附加规则.查看Wordpress文档,此规则不再适用于Wordpress 3.5+版本(新安装),因为不再使用ms-files.php,因此可以将其删除.
  • [以下以下规则现在不同步!]
  • 规则3:与无效的web.config规则2相同.
  • 规则4:与原始web.config的规则3相同.
  • 规则5.几乎相同,但是后向引用url ="{R:1}".是不同的.工作版本使用url ="{R:2}".我在其他地方也看到了此修复程序.
  • 规则6:这类似于原始文件中的规则5,但正则表达式较短;但是,在我看来,这些正则表达式可能等同于同一件事.我坚持使用较短的版本.
  • 规则7:与原始web.config中的规则6相同.

留给我一个经过重新设计的版本,现在看起来像这样:

Leaving me with a reworked version which now looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="WordPress Rule 1 Identical" stopProcessing="true">
                    <match url="^index\.php$" ignoreCase="false" />
                    <action type="None" />
                </rule>

                <rule name="WordPress Rule 3 Identical" 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 Identical" 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 R2" 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 Shorter" stopProcessing="true">
                    <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
                    <action type="Rewrite" url="{R:2}" />
                </rule>


                <rule name="WordPress Rule 7 Identical" stopProcessing="true">
                    <match url="." ignoreCase="false" />
                    <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

这篇关于如何使用子目录在Azure上设置Wordpress多站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆