Setup Virtual host in Wamp Server

I have seen lot of developers working with wamp server will come up with the relative path problem

The best solution for the relative path problem is Creating virtual host.

Here are the procedures to setup virtual host in your wamp server

There are two files involved:

– hosts (this file is in the c:\windows\system32\drivers\etc\ folder)
– httpd.conf (this is in your Apache install’s ‘conf’ folder – mine is c:\wamp\Apache2\conf\httpd.conf)

When you open the “hosts” file, you will see this line at the bottom: localhost

All you do is make another entry underneath it for your client site: myclient.local (Use whatever extension you want (ex: .local))

…and save the file. You can make as many as you want for as many clients as you want. Just keep adding more lines like that last one. Basically what happens is when you type ‘myclient.local’ into a browser now, windows will check the ‘hosts’ file before checking the internet.

Now you need to open the httpd.conf file and add a couple things.

#NameVirtualHost *:80

…then add some crap underneath it to reroute ports and whatnot. If you’re in the same boat as me, this doesn’t work because ‘#NameVirtualHost *:80′ is not in my httpd.conf file.

Here’s what I did instead. Underneath ‘DocumentRoot “c:/wamp/www”‘ add this chunk of code:



ServerName localhost

DocumentRoot “C:\wamp\www”


…then underneath that add this chunk:


ServerName myclient.local

DocumentRoot “C:\wamp\www\Clients\MyClient”


…obviously you’ll need to modify the code a bit to match the server name with the one from your ‘hosts’ file and the DocumentRoot with your client’s file path.
But that’s basically it. The problem you have now is that when you try and access your files from another computer on your local network,
the sites somehow revert back to not liking absolute paths.


Working For Cause Not For Applause

Tagged with: , , , ,
Posted in Drupal, PHP

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: