MU is virtually yours

MU is virtually yours

One of the hardest, and ultimately neato-cool features of MU is the way it creates user's blogs. On installation, you are given the choice of subdomains (username.domain.tld) or subdirectories (domain.tld/username/).

Either way, the site admin does not have to create subdomain or subdirectories for users. They exist only in the database. You will not find them on the server at all. I frequently see this question being asked in the forums from people who have accounts with subdomain limits. WPMU blogs don't count towards that.

The options for this are stored in the database and are handled by Apache's rewrite rules. Let's have a look at how this is accomplished.

The first direction served up is within the httpd.conf file. Somewhere in there is a line like this:

ServerAlias domain.tld *.domain.tld

On a regular, non-virtual domain, the *.domain.tld won't be there. This line above tells the system that anything.domain.tld is allowed, and that the system will answer requests for any subdomain. Also, in the DNS records a line like this will be there:

*.domain.tld. 14400 IN A your.server.IP.address.

This tells the system that this domain lives at this IP address.

Moving on, the rewrite rules live in the htaccess file. This directs file requests to their proper spots. The default htaccess file created on installation looks like this:

RewriteEngine On
RewriteBase /

#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

The htaccess for subdirs is the same. Apache uses mod_rewrite to create URLs on the fly for the entries that exist in the database.

Now that Apache has handled the request for the blog, it lands on the folder where WPMU is installed. MU then looks up the blog information in the database, and serves it up.

  • Peter - Antpeks
    Posted at 11:05h, 15 January Reply

    and again this is a excellent tutorial on the sundomain features that are available for WPMU.

    thnaks Andrea

  • chris frerecks
    Posted at 07:02h, 16 January Reply

    yes, it is. thanks AR. chris

  • Patrick
    Posted at 00:31h, 20 January Reply

    can u help me with this? i have not that good knowledge with sql…

  • Firewall’s Weekly WordPress, Twitter and Web News
    Posted at 18:12h, 29 January Reply

    […] some web hosts have a restriction on how many subdomains your hosting account allows. Fortunately, subdomains in WPMU can be managed virtually, to circumvent any such […]

  • Golf Balls
    Posted at 02:36h, 30 January Reply

    One prob is that In wp-includes/wpmu-functions.php function install_blog_defaults doesnt work right, what works is creating first blog, about page, blogroll and first comment. It doesn’t create the first post or the links to be added to the blogroll.

    • Christian Wach
      Posted at 15:36h, 20 May Reply

      This is to with fault-intolerant database table definitions – on Windows, inserts will fail if defaults are not set for some columns.

      In WPMU 2.7.1, fix the blogroll inserts by adding link_notes to the insert arrays beginning on line 1430, eg:

      $wpdb->insert( $wpdb->links, array('link_url' => 'URL deleted', 'link_name' => '', 'link_category' => '1356', 'link_owner' => $user_id, 'link_rss' => 'URL deleted', 'link_notes' => '') );

      (Note: I had to delete the URLs in the array to get this comment past this blog’s spam filter)

      Fix the first post insert by adding the following to the insert array beginning line 1444:

      'to_ping' => '',
      'pinged' => '',
      'post_content_filtered' => '',

      Hope that helps,


  • Monkey Girl
    Posted at 23:03h, 02 February Reply

    Thx for the help.

    One question…what has to be done to make sub domains work on an IIS6 server (win 2003)?

    I understand that a wildcard(?) needs to be added to our domain’s DNS record. Is it adding a CNAME of ” * ” ?

    We use Plesk control panel and can add this our selves. Is it another name that has to be added?

    Also, I see that there are a few things that have to be done on the server side for apache, but what about IIS6 (Win 2003) ?



  • Monkey Girl
    Posted at 01:13h, 03 February Reply

    …re above:

    of course I mean in reagrds to making wpmu work using subdomians.

    : )

    I can get mu running and creating add’l blogs…….just can’t surf to them.

    We setup wpmu to use subdomains on the install.

    We also added the * cname to our dns but waht else
    needs to be done.

    thx again.

  • Art Deco
    Posted at 17:58h, 03 February Reply

    An htaccess voodoo question:
    I bought an old wp blog where the pages were indexed in G like this

    and I am setting it up as a wpmu blog using subdomains like this

    I am writing pages with new content but keeping the same keywords, just per blog rather than per page.

    I would like G and any incoming links to see the new page automagically when it crawls the site. So far I just have the default htaccess that WPMU 2.7 creates.

    I’m trying to figure out what I should be putting in there to make the redirects work ? I don’t even know what to search for since searching G for htaccess returns the usual millions of hits.

  • Monkey Girl
    Posted at 23:36h, 08 February Reply

    Thx again.

    You stated that: “…also have to add a wildcard record to the httpd.conf file in apache”.

    But that is my problem. I’m using IIS6.

    Now, I have a wildcard * in the CNAME. But I still have to add
    a IIS entry subdomain (eg: that points to the root of the WPMU folder.

    So every blog I create, I have to create a subdomian IIS entry ?

    That is what I want to get away from….any ideas?


  • Firewall’s Weekly WordPress, Twitter and Web News « Web hosting
    Posted at 02:54h, 06 April Reply

    […] some web hosts have a restriction on how many subdomains your hosting account allows. Fortunately, subdomains in WPMU can be managed virtually, to circumvent any such […]

  • menes
    Posted at 19:31h, 26 April Reply

    hey, my blogs aren’t showing up when I add them.. it just give s me a site not found page..

  • 2sticks
    Posted at 21:33h, 18 May Reply

    this is probably too cool. at least I have the experience not to jump to conclusions and start using dns functionality that will get me nowhere. hostmonster does not support the wild card precept. so i dug into my sql after creating a blog in mu and indeed, there it sat all tidy in the tables but of course invisible on the web. I haven’t done yet what you’re suggesting but it looks promising if I don’t have to mess with a support ticket. Am I understanding this correctly??? Thanks for any comment.

  • sreckop
    Posted at 12:11h, 30 May Reply

    I installed latest version of WP MU and a default .htaccess file was created.
    I installed version in sub directory.

    When I try to start blog, I see just a blog home directory structure (sub directories and files)
    So to start a blog I need to go to wp-admin/index.php and then it starts.
    However if I try to visit my blog form dashboard again puts me in my default Blog home directory structure.

    Any suggestion?

  • Kirk Ward
    Posted at 22:46h, 20 February Reply

    I’m wanting to set up WPMU and would like to point the name used in the DNS to the subdirectory type blog structure (domain.tld/username/)

    Can I do this in a way that will rewrite the domain name ( to the subdirectory (domain.tld/username/) in a way that will avoid having the blog reader seeing the tld path?


    • Ron
      Posted at 00:41h, 21 February Reply

      Not via rewrites. You can using a domain mapping plugin.

  • bassel
    Posted at 15:40h, 05 March Reply

    thanx for that

  • How to Move Multiple WordPress Subdomain Blogs to a Single WordPress 3 Multi Site Blog
    Posted at 21:26h, 22 June Reply

    […] they only exist in the site’s database. You can read more about how this is accomplished here.When including files into a single domain site (non Multi Site), you would usually place included […]

  • 3 Steps to Managing Multiple Domains with Wordpress
    Posted at 05:26h, 06 August Reply

    […] NOT have a "normal physical existence" on the server; rather they would exist only in the WordPress database.   If you are well-acquainted with the concept of "virtual hosts on Apache" […]

  • Common WordPress Multisite Problems and Solutions « Weblog Tools Collection
    Posted at 09:01h, 19 August Reply

    […] For more information, please see this article. […]

Post A Comment