• Hello,

    I want to create WordPress multisite which uses only subdomains under?*.website.com. the issue is the main domain is used for non WordPress site, and can’t be the domain of the main site. I want to create mainsite.website.com as a main site and site1.website.com, site2.website.com, site3.website.com… as sub-sites (and not site1.mainsite.website.com ….). How to do it ?

    Thank you in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    AFAIK you cannot. A subdomain multisite requires the WP installation to be in public root, where your non-WP site already resides. In some cases WP can co-habitate with another site if that site works solely by direct file requests. For example, a static site consisting of .html files where all requests lead to actual files, WP can reside in the same location because WP works by requests that do not resolve to actual files. All WP permalinks are “virtual” URLs, there are no actual server files related to any WP permalink.

    If that is not your site’s nature, something you might try (totally untested, just an idea) is installing multisite WP in a subfolder, for example /public_html/wp/. Then through your hosting account, add subdomains that all point to this /wp/ subfolder. Then add the same subdomains to multisite as you normally would.

    I’ve no idea if this would work, but it might be worth a try. The idea being that subdomain requests added via your hosting account all go to the same /wp/ folder, thus behaving much like public root would behave. The drawback of course is you’d need to coordinate sites added via WP with subdomains added via hosting account.

    bjakuben

    (@bjakuben)

    I was able to get this to work! This question was helpful for me to see when I was initially trying to get this setup to work, so I wanted to come back and add an answer in case it’s helpful to anyone. Here is our final setup:

    User-facing URLs are like these examples:
    – mainsite.example.com
    – secondsite.example.com
    – thirdsite.examplecom

    In WP Multisite, mainsite is the top level site, with the others as subsites. We are using a *subdomain* setup (not subdirectory). In the Network Admin part of WP Admin for Multisite, I set their URLs to each URL above. Our DNS routing points these subdomains back to our host.

    *Note: the DNS entries for the subsites are actually CNAMEs in the form of secondsite.mainsite and thirdsite.mainsite. So I have CNAMEs for example.com directing to our intermediary that maps the sub-subdomain URLs to the host and WP Multisite setup. (This is all a bit confusing, honestly.)

    I had to update the main (top level) site URL following these directions: https://wordpress.stackexchange.com/a/334109

    Then I had to update wp-config.sh for the top level site to match:

    define( 'DOMAIN_CURRENT_SITE', 'mainsite.example.com' );

    Finally, I had to mess around with our Google login plugin settings to allow SSO into each WP Admin site via Google. This was the final edit I needed in wp-config.php:

    define('COOKIE_DOMAIN',FALSE);

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