• Resolved rwnfrnnd

    (@rwnfrnnd)


    Hi,

    I would like to know if it’s possible to create a site network so that the primary site is on a same level subdomain just like the sites under it?

    To be more clear, let’s say the main domain https://www.example.com is using for another purpose so that I can’t use it for the network directly. Now if I still want to create this network using direct subdomains of https://www.example.com like site1.example.com, site2.example.com, …(only one level below the main domain), can I use a similar subdomain like main.example.com for the primary site as well? Otherwise, is there an alternative method to configure such a network?

    Thanks.

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

    (@bethannon1)

    Not in the way you want your urls to work.

    I think you could create the network on a subdomain: mynetwork.example.com, and then make a subdirectory type network so that the urls would be: mynetwork.example.com/site1, mynetwork.example.com/site2.

    Thread Starter rwnfrnnd

    (@rwnfrnnd)

    Thanks for the reply. At least, it’s going to help others with a similar requirement to find the thread. And possibly a good solution, because after some research, I was able to implement a network explained in my original post.

    I’m not an expert. So you should research more on each step given below before implementing them;

    1- Enable wildcard subdomains for the main domain (*.example.com).

    2- Enable wildcard subdomains for the sub-domain that you’re going to base your network (*.mynetwork.example.com). I’m not sure this step is necessary (you’ll see why in later steps) but I didn’t have time to experiment without it after things started working.

    3- Open your wp-config.php file and add this code after the system suggested code block for the multisite: define( ‘COOKIE_DOMAIN’, ”);
    So the entire multisite code block will look like this;

    /* MULTISITE CODE BLOCK */
    define('WP_ALLOW_MULTISITE', true );
    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', true);
    define('DOMAIN_CURRENT_SITE', 'mynetwork.example.com');
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);
    /* This is required for domain mapping. */
    define( 'COOKIE_DOMAIN', '');

    4- Now each time when you create a new site it’ll have an URL like this: XXXX.mynetwork.example.com
    But we need this to be changed as XXXX.example.com
    Now simply delete the unnecessary part in the auto-generated URL to get your desired site URL. That’s it. You have to repeat this step for each new site you create.

    Yes, this may not be a practical solution for some situations. And I see people are using domain mapping plugins to achieve similar results. But at the moment the above method is working for my project without a noticeable flaw. Hope I won’t encounter unexpected issues in the future, especially with WP updates.

    Few resources helped me but these two were the most helpful (one is actually the answer);
    https://wordpress.stackexchange.com/questions/114994/multisite-install-w-sub-domains-on-a-subdomain
    https://wordpress.stackexchange.com/questions/94615/how-to-set-up-wordpress-domain-mapping-on-mamp-pro/94619#94619

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Primary Site on a Same Level Subdomain’ is closed to new replies.