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.
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.
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
here 192.168.0.2 is my machine and 192.168.0.1 is dns server
It's perfectly doable, however you need at least one of the following:
If it isn't possible to add a record to your existing DNS server, but you have root on your system, then you should:
Configure Apache to use a default virtual host.
This link should help.
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.