Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using ubuntu 8.04 and apache2, for my development I need a wildcard sub domains.

for example If I go to abc.localhost/ it should redirect to localhost/

Can you guys help me out how I can achieve this in ubuntu 8.04.

thank you.

share|improve this question
up vote 1 down vote accepted

Well I Configured it after so much RnD I was not able to use /etc/hosts file because I wanted a wildcard subdomain.
- Installed dnsmasq and created a virtual domain
in /etc/dnsmasq.conf file added these lines

  • added as nameserver in resolv.conf

here is my machine and is dns server

share|improve this answer

It's perfectly doable, however you need at least one of the following:

  • The ability to add a record into your DNS server.
  • The ability to have your DNS admin to add a record for you.
  • Root on your system.

If it isn't possible to add a record to your existing DNS server, but you have root on your system, then you should:

  1. Install Bind
  2. Configure forwarders to pass unhandled queries onto your existing DNS servers.
  3. Add wildcard entries for your domain to your bind configuration.

Configure Apache to use a default virtual host.

This link should help.

share|improve this answer

While you can not do wildcards this way, you might fins simply adding entries to /etc/hosts easier than changing DNS configuration.

For example you could add the following lines:       abc.localhost       def.localhost       ghi.localhost

The OS (and therefore most applications, those that don't try be clever and do their own DNS lookups) will be default use values from /etc/hosts before looking up values using DNS servers.

Apache configuration would be the same, wether you sort the name->address mapping via DNS or via hosts file. Also, with either technique you may need to restart client applications (or force a full refresh in web browsers with Ctrl+F5) after making changes as they may cache hostname->address lookup results for a while.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.