Sub-Domains on Windows localhost

General 2 Comments

I find it useful when working on a web project to set up a sub-domain on my development PC's "localhost" Apache installation. This allows me to test the project by accessing pages via that sub-domain, treating the directory being used as the root of that sub-domain as if it were the web document root directory (i.e.: $_SERVER['DOCUMENT_ROOT'] in your PHP scripts will point to that directory when the page is launched via that sub-domain).

Setting up a localhost sub-domain in an Windows/Apache environment is fairly easy. You just need to set up a few lines of text in three files, then restart Apache. First, make sure that your Apache httpd.conf file has the following in it, adjusting the path to the "httpd-vhosts.conf" file as appropriate for your installation:

Read the rest...