How do I map a local subdomain with WAMP and dnsmasq

1

2

I have DnsMasq setup on a local Raspberry Pi box to map local devices to simple paths on the network e.g. laptop.local I use WAMP on my laptop for local web development and this setup is working extremely well, however just to tidy up URL's and for educational purposes, how could I map a subdirectory on my laptop, currently "laptop.local/website" to a subdomain instead e.g. "website.laptop.local"

Musa

Posted 2017-10-03T10:35:16.347

Reputation: 13

Answers

1

Assuming that your DNS is set up correctly for laptop.local, you will likely only need to update your WAMP configuration to make use of the appropriate Apache virtual host(s).

Configuring WAMP

  1. Create a directory to house your sub-domain(s). Make sure this is done in a location which your WAMP installation can access (e.g. under or alongside your root www folder).

  2. Open Apache httpd.conf (located in your WAMP installation under the Apache conf directory or through the appropriate menu interface e.g. Apache → httpd.conf ).

  3. Uncomment this line (remove the #):

     # Include conf/extra/httpd-vhosts.conf 
    

    which should then become

     Include conf/extra/httpd-vhosts.conf
    
  4. Open your Apache conf\extra folder and find httpd-vhosts.conf. Add something similar to the following at the end of the file:

    # Virtual host entry for website.laptop.local
    # Anything with a # is a comment
    
    <VirtualHost *:80>
    
    ServerName website.laptop.local
    #ServerAlias *.website.laptop.local
    
    # DocumentRoot should correspond to wherever the HTML files
    # for your website.laptop.local site are located. This is an example!
    
    DocumentRoot "C:/wamp/www/subdomains/my-website"
    
    ErrorLog "logs/my-website-error.log"
    CustomLog "logs/my-website-access.log" common
    
    # If you have any problems with "Forbidden", try uncommenting
    # the following (assumes Apache 2.4.x).
    
    #<Directory "C:/wamp/www/subdomains/my-website">
    
         #AllowOverride None
         #Options None
         #Require all granted
    
    #</Directory>
    
    </VirtualHost>
    
  5. Make sure to enable your alias_module and vhost_alias_module Apache modules. Usually this is done (again) through the appropriate menu interface e.g. Apache → Apache modules but can also potentially be done under httpd.conf by simply uncommenting the appropriate module lines.

  6. Restart your WAMP server.

Assuming there are no errors, website.laptop.local should now be available.

Anaksunaman

Posted 2017-10-03T10:35:16.347

Reputation: 9 278

You're welcome. Glad to help. =) – Anaksunaman – 2017-10-05T06:41:33.463