Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

3 Answers

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 example.com
in /etc/dnsmasq.conf file added these lines

address=/example.com/192.168.0.2
listen-address=192.168.0.1  
  • added 192.168.0.1 as nameserver in resolv.conf

here 192.168.0.2 is my machine and 192.168.0.1 is dns server

share|improve this answer
add comment

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
add comment

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:

127.0.0.1       abc.localhost
127.0.0.1       def.localhost
127.0.0.1       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
add comment

Your Answer

 
discard

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.