Search code examples
wampvirtualhostdomain-name

How to assign different ( real ) domains names to different virtual hosts in wamp


I have 5 real domain names and I have 5 different set virtual hosts I want to know how to connect the domain names to my virtual host I'm new to this so plz answer easy understandable answers Thanks for reading and hopefully answering


Solution

  • If I undestand your 2 similiar question correctly you have already setup 5 Virtual Hosts for your testing purposes.

    So lets assume you have example1.dev and example2.dev ... etc setup as Virtual Hosts like this

    <VirtualHost *:80>
        DocumentRoot "C:/wamp/example1/www"
        ServerName example1.dev
        ServerAlias www.example1.dev
        Options Indexes FollowSymLinks
        <Directory  "C:/wamp/example1/www">
            AllowOverride All
            Require local
        </Directory>
    </VirtualHost>
    
    <VirtualHost *:80>
        DocumentRoot "C:/wamp/example2/www"
        ServerName example2.dev
        ServerAlias www.example2.dev
        Options Indexes FollowSymLinks
        <Directory  "C:/wamp/example2/www">
            AllowOverride All
            Require local
        </Directory>
    </VirtualHost>
    

    Now if you want Apache to serve your .tk domains you need to setup a new Virtual Host for each of the new domains. I would personally suggest that you put these sites in a different folder so you still have your test domains as well as your live domains. So using example1.tk and example2.tk you would create a new Virtual Host for each domain.

    Start by copying each domain to a new folder, better still a folder that is not in the \wamp\ directory struture at all. Lets say C:\websrc for example. Then create the new Virtual Hosts in addition to your test domains like so :-

    <VirtualHost *:80>
        DocumentRoot "C:/websrc/example1/www"
        ServerName example1.tk
        ServerAlias www.example1.tk
        Options Indexes FollowSymLinks
        <Directory  "C:/websrc/example1/www">
            AllowOverride All
            Require all granted             <- to allow inet access
        </Directory>
    </VirtualHost>
    
    <VirtualHost *:80>
        DocumentRoot "C:/websrc/example2/www"
        ServerName example2.tk
        ServerAlias www.example2.tk
        Options Indexes FollowSymLinks
        <Directory  "C:/websrc/example2/www">
            AllowOverride All
            Require all granted             <- to allow inet access
        </Directory>
    </VirtualHost>
    

    Now Apache knows what to serve when it see's your .tk domains.