How to add a Virtual Host in a local WAMP Server

How to add a Virtual Host in a local WAMP Server

 

Virtual Hosts are used to respond to different hostnames e.g, www.yourspecificdomain.com, www.yourspecificdomain.org, that resolve the same address, which is in this case ‘127.0.0.1’

Virtual Hosts can be ‘name-based‘ or ‘IP-based‘. In this article, I have covered a name-based Virtual host but IP-based Virtual Host can also be used by identifying the specific IP instead of the Asterisk (*). To use a specific IP, even to resolve multiple name-based virtual hosts, specify the IP address in place of the asterisk.

 

Before anything else, we need to locate the Virtual Hosts file to begin the processs. There are two methods;

Method 1

Navigate to the location ‘C:\WAMPServer\bin\apache\apache2.4.39\conf\extra\‘ and open the file, ‘httpd-vhosts.conf‘ with your code editor of choice (In this article I used Windows default Notepad for editting the file).

 

Method 2

Open WAMP Server on your local Windows PC. On the System Tray, locate the WAMP icon, and click on it to generate a Menu with several options including; Apache, PHP && MySQL and their versions. Click on Apache, to produce another menu that has the Apache administration options. Click on httpd-vhosts.conf, to edit it with the code editor you chose during WAMP installation, which is probably Notepad++.

 

Now with both methods, we are at the same point, editting the httpd-vhosts.conf file. The file by default has the localhost Virtual Server aleady setup. Do not remove or edit the existing code. All the code we need to create a new Virtual Server, will be added on top of the existing code.

The existing code for the localhost Virtual Server should be similar to the following lines of code, if it has not been edited before and if the developers of the WAMP Server haven’t changed too much, the structure of the version of WAMP Server used during the time this article was made;

 

# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot “${INSTALL_DIR}/www”
<Directory “${INSTALL_DIR}/www/”>
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>

 

You are gonna need to add the following lines of code asis, only editting the domain to suit your need;

#
<VirtualHost *:80>
ServerName www.yourspecificdomain.com
ServerAlias www.yourspecificdomain.com
DocumentRoot “c:/wamp_server/www”
<Directory “c:/wamp_server/www”>
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>

Now save your httpd-vhosts.conf file and you may need to restart your WAMP server to apply the changes.

Now the httpd-vhosts.conf new file should look like:

 

WAMP Virtual Server
WAMP Virtual Server

SUPPORT [[:thetqweb:]] VIA

OR

BUYMEACOFFEE.COM

How to add a Virtual Host in a local WAMP Server
Hacking | thetqweb