Receive all updates via Facebook. Just Click the Like Button Below

Wildcard DNS - Wildcard Hosting

Consider your hosting company allows you to use only 3 sub domains.
But as your website grows, you might need more number of sub domains. What you will do?
Consider you want to set up https for all your sub domains.
For each sub domain you will have to buy an SSL certificates. This is costly. In such cases, you can use wildcard subdomains.

Create a wildcard sub domain. Buy 1 SSL certificate and use it for all your sub domains. It is also refer this as Wildcard hosting.

** Note **:
As a regular user, you will not be able to accomplish this task.
Contact your website hosting company for support.

The following steps are involved in Wildcard Hosting:

1. Adding the DNS entries.
2. Setting up the Apache entries.
3. Redirecting sub domain to the correct folder.


Wildcard DNS and its Implementation


Adding the DNS entries

If you have privilege to edit the DNS zone, you will have to add the following entries.
* IN A

Once the DNS propagation gets completed. You can try digging any sub domains.

All the above sub domain will point to the server.

Setting up the Apache entries

Now all the sub domains are pointing to the server. But there is no virtual
host entry for it. So you will get the Apache page.
You just need to edit the virtual host entries for that particular domain. Add a ServerAlias " * ".

<VirtualHost IP:443>
ServerAlias *
DocumentRoot /home/user/public_html/

Then restart Apache.
Now accessing any sub domains will give up the main website page.
This is not what you are looking for. You want the sub domains to point to its respective folder.

Accessing " ", should point to the test folder under " public_html " directory.
To get this done, we can use Rewrite conditions.

Redirecting sub domain to the correct folder

To make each sub domain redirect to its correct folder, you can use the
rewrite rules.
Open the .htaccess file under " public_html " and add the below given entries.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.domain\.com
RewriteCond %{HTTP_HOST} ([^.]+)\.domain\.com [NC]
RewriteRule ^(.*)$ [L,R]


Related posts:

Advertise here

picture picture

Follow us


- Tech-Tutorials

Like us

About Techcuriosity

I am Telson, the webmaster of and through this site, I share my knowledge and curiosities in the Tech World.

What We Offer

  • What is ..?
  • How to ..?
  • Difference between ..?
  • How .. works?
  • Get in Touch
    UK : +44 77 33 890 678

    picture picture

    Our Partners

  • Website Design Dubai
  • SEO Link Exchange
  • picture