I use xampp to develop and test my websites applications (wordpress, cakephp, custom apps etc) locally on my own computer and was wondering how can developers add a subdomain such that tracking.localhost points to c:/xampp/htdocs/tracking. To get that done, you will need to touch some of Apache’s coniguration files and specifically the virual hosts’ config.
I’m assuming that you are:
– using Windows and XAMPP is installed on c:/xampp
– trying to add a subdomain tracking which will be accessible through tracking.localhost
– tracking is actually a directory under c:\xampp\htdocs\tracking
1. Open up c:/xampp/apache/conf/httpd.conf and remove the # in front of “Include conf/extra/httpd-vhosts.conf” to get
# Virtual hosts
2. Open up c:/xampp/apache/conf/extra/httpd-vhosts.conf and add the following at the end of the file
3. Open up c:\windows\system32\drivers\etc\hosts and add a new entry
4. Restart XAMPP and use your browser to browse tracking.localhost. Whatever is in c:\xampp\htdocs\tracking will be served through your subdomain.
5. This method should work fine for other local webserver packages such as WAMP or EasyPHP as long as they use Apache as their HTTP server.
Please leave a comment if you find this useful or know another method of getting the same thing done.