Using addon domains with WAMPserver

Using addon domains with WAMPserver

Don’t judge here, it is not my choice here, for one of my servers I am forced to use Windows 2012 R2, I have WAMPserver installed on this server.

So, it came to a point where I needed to have different domain names pointing to different directories on the server. So I have a main domain, say for example domainname.com, but I need to have domaintwo.com on the same server. With what I am about to show you, you can have as many domains as you want, if you are working locally you can also have say local1.domain and local2.domain.

Right so how can this be done? Well, first of all I will show you how to do the local domains.

Create a new directory for the second site in the www root:

I’ll keep this as Newfolder.

Click on the WAMP icon in your task bar, hover over APACHE and click on the httpd.conf:

You’ll get:

Find:

LoadModule vhost_alias_module modules/mod_vhost_alias.so

Uncomment it (normally starts with a #. If it’s already uncommented leave it.

Find:

Virtual Hosts

Uncomment the line

Include conf/extra/httpd-vhosts.conf

Again, this may have a # in front of it, remove it. If it doesn’t leave it. Save the file and close it.

Go back to the WAMP symbol, go back to APACHE and click on httpd-vhosts.conf

Add the following code below the </VirtualHost>:

<VirtualHost *:80>
DocumentRoot “${INSTALL_DIR}/www/Newfolder”
ServerName newfolder.local
</VirtualHost>

Repeat for as many as you need, changing Newfolder and newfolder1.local to what you require.

There are other options that we won’t go to here. Save the file.

Now we need to point Windows to recognise those domains.

Open the directory:

C:\Windows\System32\drivers\etc\

Open the hosts file:

Save the file.

Go back to the WAMP icon and restart all services:

Make sure it works. I have stuck a basic HTML file into the directory for newfolder1.local

To make it so you can point your URL external to local to the server you will need to make a few changes.

To make it so you can point your URL on the net, or WAMPserver is installed somewhere else other than on the C drive add the following to the httpd-vhosts.conf:

<VirtualHost *:80>
DocumentRoot “D:\wamp64\www\YOURFOLDER”
ServerName YOURDOMAIN.COM
<Directory “D:\wamp64\www\YOURFOLDER”>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

In the hosts page use the following code instead:

111.222.333.444 YOURDOMAIN.COM

Replace 111.222.333.444 with your IP address.

Job done!

Please Login to Comment.

Notice for AdBlock users

Please support this website by adding us to your whitelist in your ad blocker.

Ad-revenue is vital for the upkeep of this site, expenses incurred include time to manage the site, hosting and domain name. You can also support this site by donating and/or registering for goPro.

With goPro you will not see any ads.

Your assistance is appreciated.

Gary