Apache errors for blog with separate TLD, in WP multisite which is itself is in a subdirectory


I have a working WordPress multisite subdirectory installation, which itself resides in a subdirectory on the server, so that the directory structure looks like this:

http://domain.tld/ –> some other things
http://domain.tld/wp/ –> WordPress Multisite
http://domain.tld/wp/blog1/ –> Some WordPress Blog
http://domain.tld/wp/blog2/ –> Some other WordPress Blog

Now I want some of these blogs to be accessible under other domain names, e.g. Blog 1 under http://otherdomain.tld. What’s the proper way to configure redirections and site URLs in this case?

I have followed the official WordPress multisite documentation. The DNS entries are set up, in the provider’s domain configuration I have pointed the otherdomain.tld domain at the /wp/ directory, and in the WordPress blog itself I have set set the site URL to otherdomain.tld.

When I open otherdomain.tld in the browser, Blog 1 opens as it should. However, when I try to login (open wp-login.php), open the admin panel (wp-admin.php) or do anything else that directly leads to a PHP file, I get a browser error ERR_TOO_MANY_REDIRECTS. But when I do anything else on the site, open any link or post, I get a 500 Internal Server Error with the following message in httpd-error.log:

[Wed Feb 26 12:31:07.551961 2020] [core:error] [pid 13360:tid 34388520448] 
[client X.X.X.X:41006] AH00124: Request exceeded the limit of 10 internal redirects 
due to probable configuration error. Use 'LimitInternalRecursion' to increase the 
limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://otherdomain.tld/

I think the loop might be related to the RewriteRule /wp/ entry in .htaccess, but I’m not sure.

Here is the .htaccess file (in the /wp/ directory):

RewriteEngine On
RewriteBase /wp/
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]

And here is the relevant section in wp-config.php (as you can see, I’ve already tried different versions of the COOKIE_DOMAIN and related options – side note: enabling any of these leads to PHP warnings about duplicate definitions in the WP debug log):

/* Multisite */
define( 'WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'domain.tld');
define('PATH_CURRENT_SITE', '/wp/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
/* some other entries in between */
define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST']); /* recommended by WordPress */
/* define( 'COOKIE_DOMAIN', '' ); /* often recommended online, doesn't work */ 
define( 'ADMIN_COOKIE_PATH', '/' );
define( 'COOKIEPATH', '/' );
define( 'SITECOOKIEPATH', '/' );
/* Cookie configuration from https://wordpress.org/support/article/editing-wp-config-php/:  
define('COOKIEPATH', preg_replace( '|https?://[^/]+|i', '', get_option( 'home' ) . '/' ) );
define('SITECOOKIEPATH', preg_replace( '|https?://[^/]+|i', '', get_option( 'siteurl' ) . '/' ) );
define('ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
define('PLUGINS_COOKIE_PATH', preg_replace( '|https?://[^/]+|i', '', WP_PLUGIN_URL ) );
, , , , rxmd 4 years 2020-02-26T08:38:23-05:00 0 Answers 75 views 0

Leave an answer