A wildcard subdomain is a DNS (Domain Name System) configuration that directs all unspecified subdomains of a website to the same IP address without having to configure each one individually.
It’s represented by an asterisk (*) in DNS records.
For example, a wildcard subdomain for *.example.com will direct traffic from any subdomain that isn’t explicitly defined (like blog.example.com, shop.example.com, etc.) to the specified IP address.
In this article, we’ll look at what a wildcard subdomain is and give examples of how you can set it up through different hosting providers and DNS services.
- A wildcard subdomain is an example of a subdomain that can be used to match any request for an undefined domain
- A wildcard DNS record, or wildcard record, is a type of Domain Name System (DNS) record that will point all existing and non-existing subdomains to a specific area
- Wildcard subdomains help people reach your website without knowing the exact name, among other helpful uses
- Adding a wildcard subdomain to any hosting service takes just about three or four easy steps
What Is a Wildcard Subdomain?
A wildcard subdomain is a catch-all route in DNS configurations that directs any unspecified subdomain of a website to a specific directory on the server.
Essentially, when you use the asterisk (*) character instead of a specific subdomain entry in your DNS settings, the DNS server will capture requests to any unspecified subdomain and handle them according to its settings.
This is particularly useful for SaaS (Software as a Service) platforms where users might have personalized subdomains (like user1.example.com, user2.example.com) but managing each as a separate subdomain would be impractical.
Developers often use wildcard subdomains for local testing environments or to allow for dynamic subdomain creation in applications.
Wildcard Subdomains Uses
Wildcard subdomains are versatile and you can find uses in various aspects of web management and online services.
Here are some common uses:
- Multi-tenant Applications—In applications serving multiple tenants, such as in content management systems or e-commerce platforms, wildcard subdomains allow each tenant to have their dedicated subdomain.
- Testing and Development Environments—Developers use wildcard subdomains to easily generate new environments for testing or staging without having to configure new DNS records each time.
- Redirection and Default Handling—They are used to redirect traffic from non-existent subdomains to a main domain or a specific page, which can improve user experience and prevent lost traffic.
- Content Localization—For websites with a global audience, wildcard subdomains can route users to locale-specific versions of the site based on their geographic location.
- Load Balancing and Scaling—In load balancing, wildcard subdomains can distribute the load across different servers or clusters, enhancing website performance and reliability.
- SEO Experiments—Some SEO strategies involve using wildcard subdomains to test various content layouts or marketing approaches without affecting the main website.
- Domain Masking—They can be used to mask affiliate links or other external links, making them appear as part of the main domain.
- Hosting multiple websites on the same server—Useful when you need to dynamically generate websites or web pages that have their own unique subdomain, but are hosted on the same server infrastructure.
DNS Wildcard Subdomain Example
An example of a wildcard subdomain in action can be seen in a SaaS application like a project management tool.
Suppose the tool is hosted on the domain projectapp.com. The service offers each user their own subdomain for a personalized dashboard.
The SaaS provider needs to set up a wildcard subdomain, such as *.projectapp.com.
This entry means any subdomain of projectapp.com not already explicitly defined will be directed to a default location, typically the application’s main server.
When a new user signs up and chooses a unique username, say ‘johndoe’, they automatically get a personalized subdomain, like johndoe.projectapp.com. This subdomain directly leads to John’s personal dashboard. The beauty of this is that there’s no need for manual DNS configuration for each new user.
If someone types a non-existent subdomain, like random.projectapp.com, the wildcard subdomain setup ensures this request doesn’t lead to an error page but is instead handled appropriately, often redirecting to the main application or a default page.
This setup simplifies domain management, enhances user experience by providing personalized URLs, and streamlines the process of onboarding new users to the SaaS platform.
How to Add a Wildcard DNS to a Subdomain
Now that you know why wildcards work well for so many website owners, try them out for yourself using these step-by-step instructions for how wildcards work with some of the top hosting providers:
IONOS Wildcard Subdomain
IONOS is a popular hosting provider known for its support staff that allows you to create and manage multiple websites from one platform.
- Log in to the Control Panel
- Select ‘Domains’ and then click on your desired domain name
- Select ‘Advanced DNS Settings’ and click ‘Add Record’
- Set the record type as ‘CNAME Wildcard’ to make a wildcard DNS record and enter the destination URL for your site in the value field before saving changes
Hostinger Wildcard Subdomain
Hostinger is a great host of choice for those looking to host multiple websites from the same hostname and account.
- Log in to your Hostinger Account and select the Domains section from the menu bar
- Select ‘DNS Settings’ for your desired domain name, then click on the ‘+ Add Record’ button
- Set the record type as ‘CNAME Wildcard’ and enter the destination URL for your site in the value field before saving changes
Let’s Encrypt Wildcard Subdomain
Let’s Encrypt is a free, automated, and open certificate authority (CA) that provides digital certificates to enable HTTPS encryption for websites.
- Log in to your account on their website
- Select ‘Certificates’ and then click on the domain name you want to use
- Click the ‘Add Wildcard Subdomain’ command and enter the destination URL for your site before saving changes
NGINX Wildcard Subdomain
NGINX is a powerful web server used for hosting websites and servers.
- Log in to your NGINX configuration file
- Locate the ‘server’ directive and then add a new ‘location’ block below it
- Set the ‘location’ as `*.your-domain-name` in the host field and define the root path of the site or page you want to direct visitors to
- Save changes before restarting Nginx for your changes to take effect
Cloudflare Wildcard Subdomain
Cloudflare is a DNS service provider that offers users the ability to manage their domain’s DNS settings with ease.
- Log in to your Cloudflare account and select ‘DNS’ from the menu on the left-hand side
- Click ‘Add Record’ and set the record type as ‘CNAME Wildcard’
- Enter your desired destination URL for the site in the value field before saving changes
Route53 Wildcard Subdomain
Route53 is a popular DNS service offered by Amazon Web Services (AWS).
- Log in to your AWS Console and select ‘Services’ from the top menu
- Choose ‘Route53’ and open up the desired hosted zone for your domain name
- Click on ‘Create Record Set’, set the record type as ‘CNAME Wildcard’, and enter the destination URL before saving changes
GoDaddy Wildcard Subdomain
GoDaddy is a popular domain registrar and hosting provider.
- Log in to the Domain Manager
- Select your desired domain name
- Click ‘Add DNS Record’ under the ‘DNS Zone File’ tab
- Set the record type as ‘CNAME Wildcard’ and enter your destination URL in the value field before saving changes
cPanel Wildcard Subdomain
cPanel is a web hosting platform that allows you to host and manage multiple websites from the same dashboard, and how to create a subdomain in cPanel is easy.
- Log in to your cPanel account and select ‘Subdomains’
- Make a new subdomain and enter an asterisk (*) in the host field before saving changes
- Select ‘DNS Zone Editor’ and click ‘Add Record’
- Set the record type as ‘CNAME’ and enter the destination URL for your site in the value field before clicking Save changes
Final Word
Wildcard domains and subdomains can be a great way to simplify the process of hosting multiple websites on the same server.
It’s important to note that they’re also helpful for directing traffic to a single source, as they will always direct users to your specified website address.
If your website needs more help beyond setting up wildcard domains and subdomains, check out our reviews of the Best Website Builders and Best Web Hosting services.
Next Steps: What Now?
- Get your website ready for new traffic with the Best Website Builders and Best Web Hosting
- Learn more about subdomains and wildcards through articles like this one
- Follow the steps above to add a subdomain to your hosting provider/DNS records service of choice
Learn More About Subdomains
How to Create a Subdomain for a Primary Domain: Comprehensive Guide
How to Create a Subdomain in GoDaddy with and without cPanel
What Is a Subdomain: Everything You Need to Know
Subdomain vs Subdirectory: Which is Better for SEO?
Domain vs Subdomain: What They Are and What’s the Difference?
How to Find All Subdomains of a Domain with Free Online Tools
SEO for Subdomains: Benefits, Disadvantages & Strategies for Success
How To Redirect a Subdomain to Url: A Complete Guide
DNS Record for Subdomain: CNAME, DMARC, A Records & more
Email Subdomain: What It Is & How to Use It
SSL Certificate for Subdomain: How to Pick and Install the Right One?
How to Create a Subdomain in cPanel: Step-by-Step Guide
Subdomain Delegation to Another DNS Service Provider: Complete Guide
NGINX Subdomain Tutorial and Setup Guide
How to Create a Subdomain in Namecheap Hosting