1

I have configured apache2 virtual host with a sub domain in the following way:

/etc/apache2/sites-available/website:

<VirtualHost *>
  ServerName website.local
  ServerAlias sub.website.local
  DocumentRoot /home/myname/dev/website/web/
  ...
</VirtualHost> 

/etc/hosts

127.0.0.1 website.local
127.0.0.1 sub.website.local

And it works! Both http://website.local and http://sub.websitel.local point to DocumentRoot. Now, how do I reconfigure this, so that any subdomain http://*.website.local will point to DocumentRoot?

Dziamid
  • 129
  • 3

2 Answers2

3

you can use a wildcard to match any subdomain name in apache:

serveralias *.website.local

the problem is the hosts file doesn't support wildcards. if you use a local dns bind service as a resolver you can register the website.local zone and create the dns wildcard as well.

user237419
  • 1,663
  • 8
  • 8
  • Thank you, that's it. For instructions on setting up DNS for this look here: http://serverfault.com/questions/188796/localhost-subdomains-with-bind9 – Dziamid Oct 08 '10 at 19:44
2

In apache.conf:

ServerAlias *.website.local

However it is not possible to use wildcards in /etc/hosts. You would need to setup a DNS server for that.

faker
  • 17,326
  • 2
  • 60
  • 69