Multisite, different domains, optional subdirectory, and htaccess
Here's the situation:
Configuration
I have a WordPress multisite setup where different sites are on different domains. Some of those sites are contained in a subfolder in their domain, some are not. For the sites where they are in a subfolder, the subfolder name is the same across all sites.
Here's the examples:
Site | URL ----------------------- Main site | example.com Site A | sitea.com Site B | siteb.com/foo Site C | sitec.com/foo Site D | sited.com
Here is the relevant part of my wp-config.php:
/* Multisite */
define( 'WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'example.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
Here is my .htaccess:
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
# END WordPress
Problem
In this configuration, Main Site and Sites A D work, but Sites B C give a 500 error. If I change RewriteBase /
to RewriteBase /foo/
then the reverse is true: Sites B C work, but Main Site, Site A site D give a 500 error.
If the effects of RewriteBase /foo/
were applied on a conditional basis only to domains where the URI started with /foo
, then I think that would solve the problem. Unfortunately, I do not understand how WordPress and .htaccess interact well enough to do this.
Does anyone have any suggestions?
Thank you.