PHP - Apache : Setting up sub domains on localhost
Search
Tag Search
jquery
plugin
html
car
client-side
htaccess
javascript
art
AJAX
disable cache
print design
cache
apache
flash
thickbox
action script
seo
subdomain
hand drawing
regular expressions
regex
301 redirect
php
bugs
svn
Recently Added
- HTML [3 items]
- SVN (Subversion) [3 items]
- jQuery [10 items]
- PHP [4 items]
Most Popular
- jQuery [10 items]
- PHP [4 items]
- SVN (Subversion) [3 items]
- HTML [3 items]
Member Options
30
Sep
Created by: robilim - Date Added: 30th September 2009 - 1 Response
Intro
Recently I've been trying to setup subdomains to run on my localhost. This will come in handy for testing html code before putting a site live. Note I'm running Apache 2.2.11 on Windows XP. The example of a subdomain is http://localhost/mysite accessed as http://mysite.localhost
httpd.conf
At the bottom of your httpd.config (for the Apache server) usually found at c:\wamp\bin\apache\apache-<version>\conf use the following lines:
# Pretty important line - got mine working
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot C:/wamp/www/mysite
ServerName mysite.localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot C:/wamp/www
ServerName localhost
</VirtualHost>
hosts
Running on windows you will need to change the hosts file to reference the subdomain on the correct IP address. This can usually be found at c:\windows\system32\drivers\etc. Example lines here:
127.0.0.1 localhost
127.0.0.1 mysite.localhost
Hopefully this helps someone as it took a good couple of hours of searching before I found the right solution for my application.
Extra Comments:
robilim - 21 Jan 2010
Yay, this helps!

