Wildcard subdomains can be used when you want to redirect all your visitors to your main website regardless of what subdomain they type in. It is also a requirement if you are setting up WordPress multisite with subdomains.
This is also useful if someone mistypes the www in your web address, for example ww.yourdomain.com.
Here is a guide to setting up your wildcard subdomain…
1. If your website uses cPanel, the easiest way to set up a wildcard subdomain is to create a new subdomain *.yourdomain.com. On the home screen, click subdomains and add the required info (see below).
You must make sure that the subdomain’s Document Root is public_html or the directory that your website resides in.
1. If your website uses cPanel and you have access to WHM, you can log in to WHM and go to Edit DNS Zone. Select the domain name you wish to add the wildcard subdomain to.
Then, under Add New Entries Below this Line you should fill in the fields so that they look similar to the following:
* 14400 IN A 0.0.0.0
0.0.0.0 should be the IP of the account.
3. Another method used to enable wildcard subdomains is to edit the httpd.conf file. But to do this, you must have root access to the server.
Firstly, log in as root user and open the httpd.conf file (the file is commonly found in /etc/httpd/conf) with a text editor. Then find the VirtualHost entry. It should look like the following…
ServerAlias www.yourdomain.com ServerAdmin email@example.com DocumentRoot /home/yourdoma/public_html/joe ServerName yourdomain.com User yourdoma Group yourdoma BytesLog /usr/local/apache/domlogs/yourdomain.com-bytes_log CustomLog /usr/local/apache/domlogs/yourdomain.com combined ScriptAlias /cgi-bin/ /home/yourdoma/public_html/joe/cgi-bin/
The only change you need to make is change: