Enabling wildcard subdomains

Enabling wildcard subdomains

When you install WPMU by default the subdomain option is checked. This is for blogs in the format of username.yourdomain.com.

There are two steps that need to be done to your server in order for this to work.

In Apache, there needs to be a line in the domain's virtual hosts section as follows:

ServerName yourdomain.com
ServerAlias yourdomain.com *.yourdomain.com
DocumentRoot /your/doc/root/
ServerAdmin webmaster@yourdomain.com

The Server Alias line with the *.yourdomain.com is what controls this. If you do not have access to change this, ask your webhost for support. More and more hosts are enabling this by default.

The second thing that needs to be done is adding the DNS record. Where you add it depends on your domain hosting. Basically, you need to add a line like this:


These wildcards mean that any subdomain request will fall through to the WPMU install, where MU will look up the name in the database. If it finds it, it serves up the blog.

Note: if you choose the subfolder option on installation, you do not have to do either one of these steps.

  • Sean
    Posted at 11:43h, 26 October Reply

    *.yourdomain.com or *.yourdomain.com. or just *?

    At least in BIND, I think that *.yourdomain.com from within the yourdomain.com zonefile will be parsed as *.yourdomain.com.yourdomain.com

    The trailing . will tell BIND that it’s not to add the subdomain, and * simply sets a wildcard for the current domain.


    • andrea
      Posted at 11:54h, 26 October Reply

      Yep. you;re right. πŸ˜€ I was looking at a different screen and added the full domain as it was displayed. YMMV.

  • James D Kirk
    Posted at 17:43h, 26 October Reply

    And if you’re running an Nginx server, you’d use:

    server {
    listen 80;
    server_name domain.com *.domain.com;

    Note there are only spaces between the domain name listings.

  • Rahul Bansal
    Posted at 03:10h, 27 October Reply

    Hi Andrea,

    Thanks for nice article.

    Do you know how to install WPMU in subdomain mode on localhost.

    Wildcards don’t work in /etc/hosts file and nameserver is external to my machine.

    Can I somehow make this work without installing BIND on my local machine?

    Or if I can’t skip BIND, is there a good resource which explains BIND in WPMU context only.


    • andrea
      Posted at 12:37h, 28 October Reply

      If it’s your local windows box, you’ll have to put in each subdomain manually.

      If you want to read up on BIND, the only MU-specific part is “wildcard subdomains”. They are used by other applications, not just MU. Process for setting up is exactly the same.

      • Rahul Bansal
        Posted at 09:17h, 29 October Reply

        Thanks Andrea.
        I guess installing BIND locally will be better.
        For this MU project I am working on, blogs are created automatically with names decided by third party app.

    • epsi
      Posted at 08:53h, 09 February Reply

      I’ve had a little problem with DNS,
      but now it is working on my wpmu.local.

      For troubleshooting you may take a look at

      This forum using Bahasa Indonesia Language,
      but the command line output is self explanatory.

      Hope this help for anyone who experience WPMU+DNS issue.

  • Remkus
    Posted at 15:32h, 01 November Reply

    What about if you want to enable more than one domain on a server using wildcards? Do you need to enter each and every domain.tld in the Apache Virtual host section?

  • Danny G Smith
    Posted at 18:47h, 08 March Reply

    Our dns is provided by a windows domain. I don’t speak windows. Would you happen to know how to explain what needs to be done on windows?

  • Jason Mulreany
    Posted at 11:51h, 01 April Reply

    Just following on from Remkus’s question about having more than domain on a server using wildcards. I’m currently trying to do this on Lighttpd.

    I have one WPMU running like a dream on my Lighttpd VPS. I have used the virtual hosting in Lighttpd to run a separate WPMU with its own domain. The problem is that all domain mapping for this second WPMU is reverting back to the root of the primary WPMU site. Any ideas how to fix this?

  • Nephilim
    Posted at 07:26h, 15 May Reply

    Even more questions: πŸ™‚

    How do I enable wildcard sub-subdomains, like [*.blog.mydomain.com]? Should it work the same way? On my server (or rather, on my web-hosting providers server (Linux/Apache/CPanel)), it doesn’t seem to work… :-/

  • Jason Mulreany
    Posted at 16:38h, 16 May Reply

    It sounds like your using shared hosting. I would suggest that you contact your hosting company and establish if they support the use of wildcard domains on your hosting plan.
    In my own experience I have used hosting packages with the C-Panel interface that will allow you to specify wild card domain for you site but not actually support it.
    In the end I went for a Linux VPS and this allowed me full control of the wild card configuration.
    I hope this helps.


    • Nephilim
      Posted at 17:04h, 16 May Reply

      Hi Jason, and thanks for your reply!

      Yes, I’m on a shared hosting but/and they do support wildcard domains and don’t have too many restrictions overall. I have no problem creating an ordinary [*.mydomain.com] wildcard, but can’t create a wildcard domain at a deeper hierarchy [*.blog.mydomain.com].

      My hosting company doesn’t seem to know why, so I’m trying to find some information myself, so I can point them in the right direction. πŸ™‚

      This _should_ technically be possible, creating a sub-subdomain wildcard like [*.blog.mydomain.com], should it not?

      • andrea
        Posted at 17:42h, 16 May Reply

        Definitely possible, as I’ve done it. πŸ˜€

        What happens if you put whatever.blog when you create a new blog?

  • Nephilim
    Posted at 18:56h, 16 May Reply

    Good to know it can be done – I haven’t found too much information about deeper domain wildcards…

    If I create a WPMU blog named “whatever” it will get the address [whatever.blog.mydomain.com], but if I don’t manually add the subdomain [whatever.blog.domain.com] and point it to [blog.domain.com], the name will not get resolved.

    I guess this is a server/CPanel setting/issue, but your blog topic seemed close enough, and you seem to be quite knowledgeable. πŸ™‚

    The only way I have to create a wildcard domain in CPanel is with the Subdomain tool – the DNS tools (simple and advanced) won’t accept [*] as input. The problem is – when I try to add [*.blog.mydomain.com] with the Subdomain tool, CPanel reports [*.blog.mydomain.com] beeing created, but actually [*.mydomain.com] is created instead.

    • andrea
      Posted at 20:23h, 16 May Reply

      It’s because you’re on shared, basically. πŸ™‚ You’re stuck doing it this way:

      “If I create a WPMU blog named β€œwhatever” it will get the address [whatever.blog.mydomain.com], but if I don’t manually add the subdomain [whatever.blog.domain.com] and point it to [blog.domain.com], the name will not get resolved.”

      You may be able to use the multi-site plugin (we sell one, linked at the top) to create another Site called blog.whatever.com, and then create the blogs off that site. But again, it’d be a whole lot easier to do if you were in at least a vps. Then there’s some hardcore settings to fiddle.

      • Nephilim
        Posted at 11:06h, 18 May Reply

        If you have some seconds to spare – what exactly does “it’s because you’re on shared, basically” mean? πŸ˜‰

        Is this due to purely technical reasons because of the shared hosting, or do you assume my host just don’t offer this feature?

        A VPS is not an option at the moment – if this can’t be resolved, I’ll probably just register another “dedicated” domain just for the blogs, and use the ordinary [*.domain.com] wildcard possibility.

        • Andrea_R
          Posted at 14:03h, 18 May Reply

          It’s entirely technical reasons with the way most shared hosts set up their servers.

          I’ve dealt with quite a few on behalf of clients, so it’s not an assumption, it’s from actually fighting with support. πŸ˜‰

          I’ve done the same thing you want with our multisite plugin, where blog.yourdomain.com was another *site* on the system, with sub-blogs under it.

          The client I did this for may have been bumped up from the bottom-level shared account though.

          I’ve seen better hosting accounts be able to do this for as little as $15 or $20 a month.

    • Nephilim
      Posted at 13:10h, 27 June Reply

      An update – got the wildcard sub-sub-domain working! Kind of.

      Actually, it probably “worked” the whole time. I still can’t create a [*.blog.mydomain.com] domain record, but the [*.mydomain.com] wildcards really _is_ a wildcard πŸ™‚ – the [*] can consist of numerous subdomains and periods.

      I now direct [*.mydomain.com] to [blog.mydomain.com] – and [whatever.blog.mydomain.com] now works.

      The obvious drawback is that any non-existant subdomain name to [mydomain.com] now leads to my blog [blog.mydomain.com] instead of my home page [mydomain.com], but that’s really not a problem. Yet. πŸ™‚

  • I think I finally got it! | GreatDaneManiac.com
    Posted at 15:20h, 19 May Reply

    […] only sub-domains, yet still use subdirectories within the WP install. At least, that’s what Andrea mentioned in the WP […]

  • Rajesh Gurjar
    Posted at 03:46h, 26 May Reply

    Hi All,

    Please help me. I have installed WordPress MU in my local machine when i create sub domain it has created but when i run on browser it is giving me error like this “Firefox can’t find the server at sub.localhost.localdomain”
    my main domain is
    my sub domain is

    Please give me any suggestion i have tried Andrea solution but i thing i have done some mistake that is why it is not working.

    Rajesh Gurjar

    • Jason
      Posted at 11:41h, 26 May Reply

      I take it your running WPMU on you own local linux/window box and you don’t have your own DNS server running. this is a total different beast. You could try adding host entries to your host file on your cleint pc with the sub domain names and the ip address of the server.

      To get it working as per a live install like on the web you will need to setup a dns server and have your client machine resolve domain names from it.


    • andrea
      Posted at 14:50h, 26 May Reply

      If you’re on localhost, you have to create the subdomains manually in your hosts file as wildcard subdomains don’t work that way.

  • Rajesh Gurjar
    Posted at 02:07h, 01 June Reply

    Thanks Json and Andrea,

    Thanks for giving me your precious time for me. The problem is solved in local machine when we give manually sub domain on hosts file. but i want on server so i have not do the same because on server client create lot many sub domain please give me any solution for server.

    Thanks in Advance

    • andrea
      Posted at 08:49h, 02 June Reply

      On the server you have to set up wildcard subdomains.

    • Jason
      Posted at 12:08h, 02 June Reply

      There is really only one answer if you want to run it local you will need to setup a local DNS server on your lan that you can configure your wildcard dns on.

      It might be easier to find a hosting company that has a cheap hosting package that supports wildcard dns and do a test install for yourself on the web.

      Do you really want to put yourself through configuring Unix/Linux DNS or WindowsNT Server dns configuration to try it out or do you have a business case.

      We run our own internial DNS servers so adding a few non existant domains with wild card support really was not an issue.

  • George Lerner
    Posted at 19:40h, 27 June Reply

    I have WP3.0 Multi-Site (Subdomains) working on a shared hosting account (the $4.95/month kind).

    I set up wildcard DNS from CPanel, simply putting * (asterisk) in the subdomain name, for each domain I want blogs for (mydomain.com, myotherdomain.info, etc).

    I had to install WP3 in public_html for it to work, it wouldn’t work in an add-on domain. (Said another way, WP3 had to be in public_html)

    In this setup, creating a sub-subdomain, e.g. chess.blogs.mydomain.com, makes a folder chess in public_html, not in public_html/blogs. So you’d have to include that in your mapping. I haven’t tried using the Domain Mapping plugin to map to a sub-subdomain such as anything.blogs.mydomain.com; it does work fine for anything.mydomain.com.

    I made a blog post with instructions for all the changes I had to make, to have my existing web sites work and to have WP3.0 work multi-site, at WordPress 3.0 Multi-Site Installation with Existing Web Sites.

  • paul
    Posted at 09:39h, 28 June Reply


    I’ve set up my network successfully but I’m wondering how to deal with an issue:
    I want to have subdomain.example.com where example.com is a domain mapped to a virtual blog. Or it can be example.com/subdomain

    basically , I want to use subdomains or subfolders for dev sites to show clients.

    but I don’t want to use the top level domain as it is not my web design domain. So I can’t create a new blog in the multisite the normal way because it will get the subdomain.notmydesigndomain.com URL

    is this possible?


    • andrea
      Posted at 09:45h, 28 June Reply

      So you want to map each one to a subdomain of the client’s site? Yeah, you can do that wit the domain mapping plugin.

      Just use a CNAME record instead of an A record.

      • paul
        Posted at 09:56h, 28 June Reply

        Andrea, thanks for the quick reply.
        Basically, when you create a new blog on multisiite, you fill in a box which then appends .topleveldomain.com to it, so you’ll get blog.topleveldomain.com
        But I want the blog URL to be blog.sideradesign.com, where sideradesign.com is mapped to another blog on the same install : sideradesign.topleveldomain.com

        does that make sense?

        • andrea
          Posted at 10:08h, 28 June Reply

          You still need the domain mapping plugin. πŸ™‚

          You;d map the other domain, then you’d map that new subdomain to another blog.

          Either way, you still have to set up the other sites first.

          • paul
            Posted at 12:44h, 28 June

            thanks, it works perfectly.
            the only problem is that I have to ask my hosting provider to add the CNAME every time

  • marc
    Posted at 15:43h, 14 July Reply

    Hello, this seems like the right place to ask questions about Multi-sites and subdomains.

    My wife and I are photographers, and we want to have 4 sites under 1 WordPress Roof.

    1.) blackwellphoto.com
    2.) marc.blackwellphoto.com
    3.) stacey.blackwellphoto.com
    4.) weddings.blackwellphoto.com

    I am using Godaddy for my hosting and domains.

    I have a freshly installed version of WP 3.0 on my site. Following the instructions in the Codex, here’s what happens.

    I have logged into Godaddy, and in my Total DNS Control settings I added a new A (Host). For the Host Name, I put: “*”, & the Points to IP Addy field, my IP addy.

    I do not know how to follow this step: “1. Open up the httpd.conf file or the include file containing the VHOST entry for your web account.
    2. Add this line:

    ServerAlias *.example.com”

    I have added the following code: “define(‘WP_ALLOW_MULTISITE’, true);” above the ‘happy blogging’ section on wp-config.php

    I logged into WP, click tools>networks> and check “sub domains”.

    I get this warning after that: Warning! “Wildcard DNS may not be configured correctly!

    The installer attempted to contact a random hostname (76b768.blackwellphoto.com) on your domain.”

    I add the rest of the code to the wp-config file, and can’t find the .htaccess file on my site at all.

    Do I need to add the subdomains (marc, stacey, weddings) on Godaddy first? Is my DNS correct?

    Please help!

    I have set up WordPress MultiSite on blackwellphoto.com. I get all the way up to editing the .htaccess file. Why? Because I don’t have one. If I create one, the entire WP site crashes and I have to reinstall.

    After editing the wp-config.php file with the code, and logging back into WordPress I see the options to set up the network. When I click “Create New Site” it seems to work fine, however I get this code.

  • boggy
    Posted at 12:12h, 03 September Reply

    I have almost the same problem as Mark.

    When I try root installation of WPMU, the htaccess file doesn’t work. When the installation is in subdir everything is OK.

    My site is also @godaddy and the technical support there answered me that their share hosting doesn’t support wildcard DNS.

  • Ilya
    Posted at 11:30h, 07 September Reply

    I installed WPMU and it’s working good. But all of my sites have the same IP-address. I’d like that each site has it’s own IP-address. I have VPS Hosting (32 IP-addresses, Hostgator). My question: is it possible to have individual IP-address for each site?

    • andrea
      Posted at 14:14h, 07 September Reply

      Possible? Yes, but a lot of work. You’d have to have one host that will give you different IPs for each.

      Also, it’s really a non-issue seo-wise, unless you are doing thousands of links between all the sites. We have quite a few domains all in one install – the SEO is fine on them. It;s no different than hosting your site ion a shared host. (You;d share the IP there with a few hundred other domains).

  • John
    Posted at 16:40h, 27 September Reply

    Hi guys,

    First off, thanks for such a great resource! It’s been lots of help so far.

    Is it possible to have a number of subdomains that are real sites co-existing with a WP3 Network install?

    I asked my (shared) hosting provider to enable wildcards for my domain but now every subdomain, whether it exists or not, redirects to the wp blog at mydomain.com.

    I would like to have my blog running on mydomain.com, blog2.mydomain.com etc but also resolve actualsite.mydomain.com without redirecting to the default blog at mydomain.com. In this case I would want this to redirect to the subdirectory “/public_html/actualsite”.

    Is this a httpd.conf/DNS zone issue? Or is mydomain.com now the sole property of my wp blog?

    • andrea
      Posted at 17:23h, 27 September Reply

      Yep, it’s a zoning issue. πŸ™‚ Apache reads them in the order it finds them, so if the wildcard record come first, and then the subdomains…. well, you get sent to the wordpress install.

      Shuffle it around in the httpd.conf file a bit, put the wildcard last, should sort you right out.

  • pain
    Posted at 20:14h, 27 September Reply

    how do i know either my shared hosting support wild card subdomain?

    • andrea
      Posted at 20:39h, 27 September Reply

      Ask them. πŸ™‚ I’m not being silly, you really need to file a support ticket with them and ask. They will know.

  • Brian Bowman
    Posted at 05:30h, 20 October Reply

    Hey Andrea,

    I wrote out a real detailed explanation of my attempts to setup a WP 3.0.1 multiuser install on a local host mac platform – and am attempting to set that up properly so tthat I can use subdomains. I’m ok with manually updating the hosts file when needed. Can you answer the question here: http://wordpress.org/support/topic/local-installation-of-wp-multisite?replies=3#post-1747895

    Much thanks.

  • Pat
    Posted at 23:38h, 16 November Reply

    in your Cpanel go to Subdomains and in the field ” Subdomain : ” ADD an asterisk
    then hit the button create.

    so you should have

    That’s it!

    • andrea
      Posted at 10:05h, 18 November Reply

      this is the same as my step describing enabling it in your DNS records.

      in your case, your host has already done the step in Apache. that’s why it works. It’s not the same on all hosts.

Post A Comment