Wildcard domains DNS and local WAMP for website development

When developing websites on a  local WAMP installation, I often need control over the DNS. It is no problem to add a hostname to the Windows hosts file, but a wildcard in the domain does not work. For example you need a wildcard domain when installing WordPress Multisite locally with subdomains. This article has the solution to add wildcards to your local WAMP installation, without installing Bind or other heavy DNS solutions.

Configuring WAMP for wildcard domains

If you not WAMP installed already, you can find here: www.wampserver.com/en/
After the download you can install it with the default parameters.

After installation it is possible to open a webpage at http://localhost/

Enable Virtual hosts on WAMP

When WAMP is running, you will see a green icon on the task bar. To enable virtual host, we need to configure it.

Left-click on the green WAMP icon and go to menu: Apache->httpd.conf
Press in Notepad Ctrl-F and search for: httpd-vhosts
Remove the ‘#’ before the Include to include the httpd-vhosts.conf file

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

Adding Virtual hosts on WAMP

To add the Virtual hosts, open Notepad, open file and browse to this file (default installation):
C:\wamp\bin\apache\Apache2.2.21\conf\extra\httpd-vhosts.conf

In httpd-vhosts.conf  you can add the virtual hosts you need, here is an example for two virtual hosts. You can put here also more virtual hosts. Special in the configuration is the ServerAlias to provide the wildcard (‘*’) in the domain.

<VirtualHost *:80>
   DocumentRoot "C:\wamp\www"
   ServerName mydomain.local
   ServerAlias *.mydomain.local
</VirtualHost>

<VirtualHost *:80>
   DocumentRoot "C:\wamp\www"
   ServerName myotherdomain.local
   ServerAlias *.myotherdomain.local
</VirtualHost>

Now save the httpd-vhosts.conf file and restart the WAMP server.

Configuring DNS wildcards with Acrilic DNS Proxy

I was looking for a tool like this for a long time. Normally I had to configure Dnsmasq on a Linux machine, but with Acrylic it is a lot more easier and all local on a Windows machine.

Download Acrilic DNS Proxy from Sourceforge: sourceforge.net/projects/acrylic/

After installation go to menu:
Start->Programs->Acrilic DNS Proxy->Config->Edit Custom Hosts File

Add the folowing lines on the end of the file:

127.0.0.1	*.localhost
127.0.0.1	*.local
127.0.0.1	*.lc

Now you need to restart the Acrilic DNS Proxy service. Go to menu:
Start->Programs->Acrilic DNS Proxy->Config->Restart Acrilic Service

Do not forget to change your Network adapter settings:

  1. go to menu: Start->Control Panel->Network and Internet->Network Connections
  2. Right-click on your current network adapter and select Properties
  3. Now select Internet Protocol Version 4 and click on the Properties button
  4. Fill in the localhost IP number (127.0.0.1) at the DNS section (see picture) and press OK.

[shashin type=”photo” id=”1933″ size=”medium” columns=”max” order=”user” position=”center”]

The result and WordPress Multisite

Now you are able to ping a domain like: hello.mydomain.local. Also to run a website with domain names like hello.mydomain.local locally.

It is also possible to run a site like WordPress.com. This is a WordPress installation with multiple subdomains under it. Previously it was called WordPress MU. Since WordPress 3.0, multisite is integrated into the normal release of WordPress.

How to configure WordPress Multisite you can read in this article: Configuring WordPress 3 with Multisite and second level domains

9 thoughts on “Wildcard domains DNS and local WAMP for website development”

  1. I am using XAMPP (I assumed that configuration will be similar to WAMP), and I followed the instructions above.

    DocumentRoot “C/xammp/htdocs”
    ServerName mydomain.localhost
    ServerAlias *.mydomain.localhost

    DocumentRoot “C/xammp/htdocs”
    ServerName myotherdomain.localhost
    ServerAlias *.myotherdomain.localhost

    x I can ping localhost, bot nothing else. I even tried a “.local” variation. Have I missed something?

    1. It can be a lot of things, maybe your firewall?
      Pretty important is that you fill in your localhost IP address for the adapter you are using right now. Maybe you forgot that?

  2. It works! One thing – put 127.0.0.1 as primary DNS, and IP of Your router (or any other proper DNS server) as Alternative because Acrilic wont handle Your “regular” urls ;)

    1. Hi Barat, good idea to set your router as secondary DNS. Like I described, Acrilic is functioning like a DNS cache. I’m working via satellite internet and this speeds up resolving DNS request. Very handy tool :-).
      Greetings, Arjan

  3. Hey Arjan.

    Great tutorials you have here.

    I need to develop 3 sites on localhost with very similar theme, plugins etc.

    I am unsure, if this would work in WAMP.
    When the sites are ready i will have to publish them on the live production server. They will have 3 different domains though. (NO subdirectories or subdomains.)

    Therefore i would have to use the “WordPress MU Domain Mapping” plugin if i want to go the multisite route (http://wordpress.org/plugins/wordpress-mu-domain-mapping/)

    Now, i am struggling to decide whether to go the multisite route in WAMP so that i can manage all the sites with one dashboard etc. or instead to develop the 3 sites as separate single sites.

    I cant find a definite statement (let alone tutorial) that multisite with mapped domains (via plugin) works using WAMP to publish later on a live server.

    Please, if you could end my doubts… i’d appreciate a lot!

    Greets, saswata

    1. Hi Saswata,
      It’s absolutely no problem to develop everything on WAMP. But be careful with absolute path’s in the content. Everything needs to be relative.
      When you upload your database to the life environment, you need to edit the database for two home url’s in the wordpress database. Change it from http://localhost to your website url.

      Another thing is WordPress MU. My advise is don’t do it. I tried it several times, the idea is very nice and handy. The problem is the compatibility of the plugins. You need to test all plugins if it works fine for you. And this will always follow you when you want to install a new WordPress plugin. WordPress MU is not mainstream. A single WordPress installation is.

      I’m maintaining 9 websites and they are all running separate. This is quicker than working with WordPress MU. It saves you a lot of headaches :-).
      Succes,
      Arjan

  4. Thanks a TON for your valuable insight! – Will do as you say and develop single sites and look out for relative paths…

    Thanks again & god bless, S.

Comments are closed.