Using DNS to Forward All Subdomains
DNS is used to translate domain names into IP addresses. If you have ever owned a domain name, you have probably had to mess with DNS at least a little bit. In this article, I will tell you about forwarding all of your subdomains using a wildcard in your A (Host) DNS records.
Why:
Here are some situations where this would be useful:
- If you plan on using multiple subdomains pointing to the same server (and using your web server to handle them)
- If you want to redirect all subdomains to www or the root address of your domain (e.g., randomsubdomain.thejoerussell.com redirects to www.thejoerussell.com)
- If you want to redirect all subdomains not in use to somewhere
How To:
- Create a new A (Host) DNS Record
- For host, input * (this may be different depending on your DNS provider, I use GoDaddy)
- For ‘Points To’, input the desired destination IP Address
Voila! You may have to wait a while and flush your local dns.
Notes:
The wildcard is only used after all other records have been checked. All A (Host) and CNAMES(Aliases) records will be used before resorting to the wildcard. This is great if you need a few exceptions. For example: http://family.thejoerussell.com forwards to my family website via DNS, my webserver is not contacted for this.
My next article will explain how to handle multiple domains and subdomains on the same ipaddress and server using apache.