Use Top-Level-Domain (TLD) Wildcard in Apache Virtual Host

Written by - 0 comments

Published on - Listed in Internet Linux Unix Apache

An Apache (2.2) virtual host can use wildcards for subdomains, as it is described on the official Apache documentation for Serveralias:

 The ServerAlias directive sets the alternate names for a host, for use with name-based virtual hosts. The ServerAlias may include wildcards, if appropriate.

In the example on the same page, the following VirtualHost section is shown:

<VirtualHost *:80>
ServerAlias server server2
ServerAlias *
UseCanonicalName Off
# ...

In this example a wildcard for all subdomains of (* is used.

But what if someone wants to use wildcards not only for a domain, but for a whole TLD, let's say for *.com?
I was surprised... it works!

For a testing scenario, I created two vhosts:

<VirtualHost *:80>
  ServerAlias *.ch
  DocumentRoot /home/www/ch

<VirtualHost *:80>
  ServerAlias *.fr
  DocumentRoot /home/www/fr

When I accessed "" (just some fantasy domain name with the .ch tld and pointing to the web server's ip address), the correct index page was shown. The same happened, when I access

Setups like these can be helpful on a dedicated Apache web server for a multinational company, where each country has its own website.

Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.

RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder