Because it’s nicer, handier and sometimes just plain necessary to refer to ‘test-sites’ on your development machine as http://project instead of http://localhost/project. (first time I needed it was when breaking my head over mod_rewrite)
I’m still running a Fedore Core 3 Linux installation here, but I guess this will be the same on 90% of standard Linux installations.
Add the fake domain to /etc/hosts, so your computer knows the ip addres (=local) and doesn’t need to query dns (which won’t work).
Also change apache httpd.conf to add the domain and the corresponding ‘root path’.
Add the domain to /etc/hosts
Add the domain to your /etc/hosts file, either as a new domain pointing to your local ip (127.0.0.1), or as an alias to your machine’s entry that’s already in there. Look for the following line (there’s probably only one in there):
127.0.0.1 localhost.localdomain localhost
Now add your ‘test’ domain, let’s call this one ‘project’:
127.0.0.1 localhost.localdomain localhost project
Now ‘ping project’ and you’ll see the ping going to 127.0.0.1. NO REBOOT NEEDED (only a save ofcourse), this isn’t windows!
Change Apache httpd.conf
Next, we need to add the virtual domain to apache’s config file, which is located at /etc/httpd/conf/httpd.conf (on FC3, otherwise ‘find’ it). At the end of httpd.conf, add the following (let’s pretend the root of our domain is located at /var/www/html/project on the filesystem):
Use ‘service httpd restart’ to restart Apache with the new config. (if this doesn’t work, try ‘httpd -k restart’)
Open a browser, surf to’ http://project’ => bingo!
Running Windows ?
I haven’t tested this, but I guess instead of adding your domain to /etc/hosts, you’ll need to find a file called ‘lmhosts’ (no extension!) and add your domain pointing to 127.0.0.1 there. I *think* the apache httpd.conf modification will be the same.