How to Setup WordPress Multisite with Subdomain

How many blogs do you have? Have you ever feel bored when it’s time to update wordpress, themes and plugins, because you have to do it one by one? Do you want to have your own blog network, like WordPress.com? If yes, then I think you should consider to setup a wordpress multisite.

Step by step to setup a wordpress multisite

I assumed we’re using a fresh install wordpress, so we don’t have any datas to backup. Also I’m using cPanel as an example.

  • Create a wildcard subdomain
    Create a Wildcard Subdomain

    Create a Wildcard Subdomain

  • Create a wildcard DNS A record. Go to Simple DNS Zone Editor, select the domain name, put * (wildcard) as Name, and your web hosting IP address as the Address.
    Create a Wildcard DNS

    Create a Wildcard DNS

  • Edit wp-config.php, add these lines above the line that says
    /* That's all, stop editing! Happy blogging. */

    So your wp-config.php file become like this:

    /* Multisite */
    define('WP_ALLOW_MULTISITE', true);
    
    /* That's all, stop editing! Happy blogging. */
  • Refresh your wordpress dashboard. Go to Tools menu and you should see a new menu called Network Setup
    Wordpress - Tools - Network Setup Menu

    WordPress – Tools – Network Setup Menu

  • Previously, we already setup the Wildcard Subdomain and Wildcard DNS, so for the Addresses of Sites in your Network, select the Sub-domains
    Addresses of Sites in your Network

    Addresses of Sites in your Network

    Make any other necessary changes, and click the Install button.
  • If you see some warning messages like this one, just ignore it, because we already configured our Wildcard DNS.
    Warning! Wildcard DNS may not be configured correctly!

Enabling the Network

Complete the following steps to enable the features for creating a network of sites.

Caution: We recommend you back up your existing wp-config.php and .htaccess files.

  1. Create a blogs.dir directory at /home/<hostname>/public_html/<your-domain.com>/wp-content/blogs.dir. This directory is used to store uploaded media for your additional sites and must be writeable by the web server.

  2. Add the following to your wp-config.php file in /home/<hostname>/public_html/<your-domain.com>/ above the line reading /* That’s all, stop editing! Happy blogging. */:

    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', true);
    $base = '/';
    define('DOMAIN_CURRENT_SITE', '<your-domain.com>');
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);
  3. Add the following to your .htaccess file in /home/<hostname>/public_html/<domain.ext>/, replacing other WordPress rules:

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    
    # uploaded files
    RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule . index.php [L]

Once you complete these steps, your network is enabled and configured. You will have to log in again.

How to Allow New Registration in WordPress Multisite

Go to Network Settings » Registration Settings » Allow new registrations, select the Both sites and user accounts can be registered.

Wordpress Multisite Allow New Registrations

WordPress Multisite Allow New Registrations

That’s all folks. Your very own wordpress multisite with subdomain is now ready. Hope it helps. 🙂