Support » Networking WordPress » Separate domain for blog in WP multisite that is itself in a subdirectory

  • phrxmd


    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:

    Now I want some of these blogs to be accessible under other domain names, e.g. Blog 1 under 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 http://otherdomain.tld.

    All sites on the multisite work fine as long as I open them under http://domain.tld. When I open http://otherdomain.tld in the browser, Blog 1 also opens as it should; however, when I try to login into Blog 1 (open wp-login.php), open its admin panel (open wp-admin.php) or do anything else that directly leads to a PHP file, I get a browser error ERR_TOO_MANY_REDIRECTS. Now when I do anything else on the Blog 1, 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  
    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 ) );
    • This topic was modified 3 months ago by phrxmd. Reason: Fix formatting
    • This topic was modified 3 months ago by phrxmd.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Moderator bcworkz


    Have you tried pointing otherdomain.tld to /wp/blog1/ folder? If your hosting control panel won’t let you because the folder does not exist (it cannot exist for WP to work), leave it at /wp/ and do a redirect in .htaccess for any otherdomain.tld to go to /blog1/

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.