Creating a Virtual Host on WAMP
Fri, 28 Jan 2011After you install WAMP on windows you may want to create directories dedicated to HTTP addresses so it's easier to navigate projects. To do so, first open your httpd.conf file in Apache, you can get to this from the task bar:
Next, scroll to the very bottom of the file, and copy and paste this:
<Directory "C:\Workspace"> AllowOverride AuthConfig FileInfo Indexes Limit Options Order Deny,Allow Allow from all </Directory> NameVirtualHost 127.0.0.1 <VirtualHost 127.0.0.1> DocumentRoot "C:\Workspace" ServerName workspace </VirtualHost>
Obviously you have to replace the "C:\Workspace" in both spots with wherever you are going to host your files.
Next, you tell Windows to point the http URL to your directory, this part seems a little weird because its a system file, but it's very easy. Navigation to C:\Windows\System32\drivers\etc and open the hosts file. Just open it with Notepad.
You'll see something like this:
127.0.0.1 localhost
Now just append your server name onto the end to whatever you called your ServerName in Apache:
127.0.0.1 localhost workspace
Now Restart your WAMP server from the taskbar, and go to http://workspace (or the URL you made). Also, make sure you have an index.php file inside your C:\Workspace folder so something shows up.