Search This Blog

Thursday, May 3, 2012

Using wildcards in Apache server aliases

Using wildcards in Apache server aliases:


Apache allows you to create hundreds of virtual host containers. Each container is required to have a ServerName directive, which contains the domain name associated with the virtual host. In addition to a server name, one ore more aliases can be associated with the virtual host with the ServerAlias directive. Aliases can contain a domain, or a regex that allows you to match based on some specific criteria. This is super useful, and allows you to do things like this:
NameVirtualHost 192.168.1.18:8080

<VirtualHost 192.168.1.18:8080>
     ServerName foo.com
     ServerAlias *.foo.com
</VirtualHost>

<VirtualHost 192.168.1.18:8080>
     ServerName bar.com
     ServerAlias *.bar.com
</VirtualHost>
This opens a whole slew of cool and interesting possibilities for virtual hosting. Niiiiice!

No comments:

Post a Comment