A question on WordPress Multisite running on Windows Azure using Sub-directories: does it work? how do you do it?.
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).
So, for example, the base website:
http://mywordpressmultisite.azurewebsites.net
works fine. But the multi-sites:
http://mywordpressmultisite.azurewebsites.net/site2/
http://mywordpressmultisite.azurewebsites.net/site3/
Display an unstyled css website, but I can’t really do anything with them since I have no admin access; a routing error perhaps.
More Details
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).
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>
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);
Things I’ve tried
- Using both the Free and Shared hosting solutions.
- Checking permalinks work on standard wordpress and the base No1 site (so
mywordpressmultisite.azurewebsites.net/helloworld works). - Scrubbing down the database and starting the whole process again.
- Changing file permissions to allow read, write and execute; just in case.
Debugging
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);
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.
This stackoverflow question on IIS has the answer:
getting 404 error on admin panel for sub-directory multisite on a sub-domain in wordpress
It gives this XML for the web.config
I’ve uploaded this to Azure and it works. Theme’s and dashboard are now accessible.
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.
Edit:
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
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.
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 File Differences
Referencing rules from the working web.config in relation against those in the one which doesn’t work:
Leaving me with a reworked version which now looks like this: