HomeLinuxDomainHow To Set-Up Wildcard Domains

How To Set-Up Wildcard Domains

Setting up a wildcard domain allows you to manage multiple subdomains with a single configuration. This is particularly useful for applications that need to handle dynamic subdomain creation or manage numerous subdomains efficiently. In this guide, we will provide a detail explanation of what is wildcard domains, Advantages and how to setup wild card domains …

Wild card domains

What is Wildcard domains?

wildcard domains

A wildcard domain is a domain name system (DNS) record that matches requests for non-existent subdomains. It is specified by using an asterisk (*) as a placeholder for any subdomain. For example, *.example.com would match any subdomain like blog.example.com, shop.example.com, or any other subdomain under example.com.

Advantages of Wildcard Domains

  1. Ease of Management:
    • Simplifies DNS management by reducing the need to create separate records for each subdomain.
  2. Scalability:
    • Allows for the automatic handling of new subdomains without additional configuration.
  3. Flexibility:
    • Ideal for applications where subdomains are created dynamically, such as multi-tenant applications.
  4. Reduced Configuration:
    • Minimizes the need for manual updates and maintenance.

Guide to Setup Wildcard Domains

A wildcard domain allows all subdomains of a domain to be directed to a single location. For example, *.example.com will include blog.example.com, shop.example.com, and any other subdomain.

Configuring DNS Settings

  1. Login to your DNS management panel:
    • Navigate to the DNS management section where you manage your domain records.
  2. Create a new A Record:
    • Add an A record with the following details:
      • Host: *
      • Points to: [Your Server IP Address]
    • This will route all subdomains to the specified IP address.
  3. Adding CNAME Records:
    • If you prefer to use CNAME records, create a CNAME record with the following details:
      • Host: *
      • Points to: example.com
    • This will alias all subdomains to the main domain.

Setting Up Wildcard Domains in cPanel

1.Login to cPanel:
->Use your credentials to access your cPanel account.

2. Navigate to the Domains Section:
->Click on Subdomains/Domains.

3. Add a Wildcard Subdomain:

-> In the Subdomain field, enter *.
-> Select the domain you want to add the wildcard for:

wildcard domain creation in cpanel

The Document Root will automatically populate. You can change it if needed, but typically, it’s set to /public_html.

4. Click Submit.

Configuring Apache

If you are using an Apache server, you need to enable wildcard subdomains in your virtual host configuration.

  1. Open your Apache configuration file (usually located in /etc/httpd/conf/httpd.conf or /etc/apache2/sites-available/000-default.conf).
  2. Add the following configuration:
<VirtualHost *:80>
    ServerAlias *.example.com
    DocumentRoot /var/www/html
</VirtualHost>

3. Restart Apache:

Run the below command .

systemctl restart apache2         or 
systemctl restart httpd

Verifying the Setup

  1. Test your Wildcard Subdomain
    • Open a web browser and navigate to any subdomain, such as test.example.com.
    • It should direct you to the main domain’s document root or the specified folder.
  2. Troubleshooting
    • If it doesn’t work, check your DNS propagation. It can take up to 24-48 hours for DNS changes to propagate fully.
    • Ensure your server and DNS configurations are correct.

Limitations of Wildcard Domains

  1. Wildcard Certificates:
    • SSL/TLS certificates need to be wildcard certificates to cover all subdomains, which might be more expensive.
  2. Subdomain Control:
    • Limited control over individual subdomains as they all point to the same location.
  3. DNS Propagation:
    • Changes can take up to 24-48 hours to propagate, affecting new subdomains immediately.

Conclusion

Setting up wildcard domains can simplify the management of multiple subdomains and improve your website’s scalability. Follow these steps carefully to configure wildcard domains for your website. If you encounter any issues, consult your hosting provider for support.

Related Searches :-

Configuring Name servers on cPanel server
Proxy Subdomains
Scroll to Top