WordPress Multisite, Subdomains and Subfolders

The agency I work for recently converted a client with numerous, restaurant sites over to a WordPress multisite install. When we set it up to work on a staging server we used a “staging” subdomain for each individual site. The default functionality is to work on a root install of WordPress but this wasn’t going to work when the site that served as the root for the WordPress install was also installed on a “staging” subdomain.

The Root WordPress Install

We’re going to use my most recent experience as an example. In this case, the root WordPress install was set up as staging.example.com. Which, in this case, is stored in a “staging” subdirectory on the server and just uses a subdomain to point to it. With this setup the other staging domains would point to staging.example.com

The Other Sites

When it comes time to point the other domains at the root install I used a custom CNAME in the DNS settings to point to the root install.

staging.example-two.com.    28800    IN    CNAME    staging.example.com.

When the DNS propogates the second subdomain will point to the same server as the root install but it won’t be pointing to the correct subfolder. In order to accomplish this we have to configure the server to direct the new domain name to the correct, “staging,” subfolder. The server running the root install was using cPanel so this was accomplished by logging into cPanel and creating a new “addon domain” to point staging.example-two.com to the right folder.

Screenshot of the location of the "Addon Domains" link in cPanel

In the new window we enter the Domain name (staging.example-two.com), FTP username (not really important), document root (The location of the root install – public_html/staging) and password (not really important either, but should be secure).

Screen-Shot-2013-10-24-at-1.42.32-PM

Once saved, this will create the DNS settings necesary to point the new domain at the root install. When the time comes to remove the “staging” prefix and launch the sites it’s as easy as moving the root install into the public_html folder, deleting these original entries and then adding new ones that point the public_html folder instead of the public_html/staging folder.

Conclusion

This worked in our case. I’m not sure how it works with other software like Plesk. Or worse on a server with no software at all that has to be configured via the command line. If you have something to add to this, please let me know by leaving a comment.

2 Comments on “WordPress Multisite, Subdomains and Subfolders”

  1. Mummy Ninja says:

    How can I do this if I don’t have cpanel? :(

    • Jeremy says:

      I imagine there’s some way to do it through command line, thought I can’t say I know how one would go about that. All cPanel really does it make managing the server easier. All the options should be available without it.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>