How to add a wildcard DNS record?

Wildcard subdomains are useful when you wish to redirect all visitors to your main website regardless of what subdomain they access your website through.

This is also useful when someone mistypes www for example and writes ww.yourdomain.com.

In other words, with wildcard subdomains it won't matter whether someone accesses your site throughww.yourdomain.com or wwwwww.yourdomain.com.

Here are three ways to enable wildcard subdomains for your website:

1) The easiest way to enable wildcard subdomains is to create a subdomain *.yourdomain.com. Hostlantern customers can do this from their cPanel > Subdomains.

You should make sure that the subdomain's Document Root is public_html.

2) If you are using cPanel and you have access to WHM, you can log in to WHM and go to Edit DNS Zone. Select the domain you wish to modify from the list of available websites.

Under Add New Entries Below this Line you should fill in the fields so that they look like:

*                       14400            IN                     A               1.2.3.4

where 1.2.3.4 is the IP of the account

3) Another way to enable wildcard subdomains is to directly edit the httpd.conf file. (For this you will need root access to the server hosting the account.)

Log in as root and open the httpd.conf file (usually this file is located in /etc/httpd/conf) with a text editor such asvim or nano. Then find the VirtualHost entry for the website. It should look like:

<VirtualHost 67.15.245.5>
ServerAlias www.yourdomain.com
ServerAdmin webmaster@yourdomain.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/
</VirtualHost>

The only modification you need to make is change:

ServerAlias www.yourdomain.com

to

ServerAlias *.yourdomain.com

If you are not yet a customer, check out what our domain services include and how we can make your life easier. Managing your own domain is easy when you have the right host by your side.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to update the whois information for a .UK domain

The primary registrar for the .uk domains (including .co.uk, .org.uk, etc.) is Nominet. Their...

What is DNS propagation and why does it take so long?

In order to resolve a domain name, it must be registered and pointed to at least two name servers...

How to add SRV record in cPanel

You can add SRV record from your cPanel by following the steps below:1. Login to your...

How to change the nameservers for your Swiss domain?

If the nameservers you plan to use for your domain name are not registered with Switchplus, you...

What is a PTR record and how to add one?

You can think of the PTR record as an opposite of the A record. While the A record points a...