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:
*. in A YOURIPADDRESS
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.
*.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.
Sean
Yep. you;re right.
I was looking at a different screen and added the full domain as it was displayed. YMMV.
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.
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.
Thanks,
-Rahul
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.
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.
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
http://forum.linux.or.id/viewtopic.php?f=12&t=20978
This forum using Bahasa Indonesia Language,
but the command line output is self explanatory.
Hope this help for anyone who experience WPMU+DNS issue.
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?
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?