Support » Networking WordPress » WordPress Multisite Subdomains on Apache not Working

  • I am converting my WordPress multisite from a subfolder to the subdomain, trying to add a new site in a I have configured A Record on Cloudflare and configured a virtual host on Apache. I can access my successfully and I can see the index.html page.

    Directory permission set to 755 and www-data:www-data is the owner of the directory

    Added the following in wp-config.php

    define( 'WP_ALLOW_MULTISITE', true );
    define( 'MULTISITE', true );
    define( 'SUBDOMAIN_INSTALL', true );
    define( 'DOMAIN_CURRENT_SITE', '' );
    define( 'PATH_CURRENT_SITE', '/' );
    define( 'SITE_ID_CURRENT_SITE', 1 );
    define( 'BLOG_ID_CURRENT_SITE', 1 );

    Added the following in .htaccess because WordPress on Network Settings suggested adding it.

    RewriteEngine On
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    # add a trailing slash to /wp-admin
    RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
    RewriteRule ^(.*\.php)$ $1 [L]
    RewriteRule . index.php [L]

    When I try to add a new site on WordPress, I am getting different errors

    Warning: require_once(/var/www/mysite-com/public_html/wp-content/themes/twentytwentyone/inc/classes/class-mobile-detect.php): failed to open stream: No such file or directory in /var/www/mysite-com/public_html/wp-content/themes/bombom/inc/structure/mobile.php on line 5

    Fatal error: require_once(): Failed opening required ‘/var/www/mysite-com/public_html/wp-content/themes/twentytwentyone/inc/classes/class-mobile-detect.php’ (include_path=’.:/usr/share/php’) in /var/www/mysite-com/public_html/wp-content/themes/bombom/inc/structure/mobile.php on line 5

    There has been a critical error on this website.

    After adding the new site in the subdomain I get an error “There has been a critical error on this website.” but after refreshing the page I can see under the Sites section but once I click on the Subdomain’s Dashboard ( I get error 404. The subdomain directory is also empty on Unix Server.

    Can anyone please guide me where is the problem? Why does WordPress fail to install required files in the subdomain?

Viewing 1 replies (of 1 total)
  • I can access my successfully and I can see the index.html page.

    This is the root of your error 404 problem on the subdomains.

    WordPress Multisites paths (subdomain or subdirectory) are virtual. This means there should be no separate DocumentRoot for them at all!

    Before creating the subdomain site in WordPress, opening the subdomain URL in the browser should open the primary website, and not its own page.

    This then allows WordPress to take over the URL and display the appropriate subsite (if it exists) or display the appropriate message depending on the network’s registration settings.

    If the subdomain has its own DocumentRoot and opens its own site, then that VHOST is being served independently of the WordPress site which is in a different DocumentRoot.

    There are a couple of ways to do this:

    — Instead of the A-record, CNAME the subdomains (individual subdomains or the wildcard subdomain) to the primary domain at Cloudflare. No config in Apache may be needed at all.

    — With A-record, add the subdomains as ALIAS in the root domain’s VHOST config. So no separate VHOST needed for the subdomains.

    — With A-record, and using different VHOST for the subdomains, set the subdomain’s DomentRoot to be the same as that of the primary WordPress site’s DocumentRoot.

    (Note that the above are general ideas for doing this, but actual implementation details may vary slightly from the above depending on how your server is set up and how your domain is configured in Cloudflare.)

    However you approach this, the end result should be what I mentioned earlier: before creating the subdomain site in WordPress, opening the subdomain URL in the browser should bring up the root domain’s primary WordPress site, and not a different page.

    As to the warning and critical errors, it seems a file is missing from your active theme. I’ll advise that you check the bombom theme folder to see if the file in question exists, and/or switch to a different theme to see if the problem goes away.

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