Sunday, 13 September 2015

Xamp dynamic vertual hosts with a lookback URL

This is a short tutorial how to get up and running with dynamic virtual hosts with XAMPP on Windows.



The goal of this tutorial is to be able to create a URL like “htdocs_dir.loopback.com” in your C:\xampp\htdocs\ so virtual host are made dynamically.

1 : Loop back URL
a  loop back is a url that dynamically points to back to local host .  (*.loobback.com)
a good URL to use is vcap.me witch is pre configured to map local host. 

2 :  Enable vhost_alias_module modules in  the httpd config this can be found in
  C:\xampp\apache\conf\httpd.conf
Find Load Module vhost_alias_module modules/mod_vhost_alias.so and remove the ( # ) from the start . 

3:  Enable virtual hosts in the config file

C:\xampp\apache\conf\extra\httpd-vhosts.conf 
 add this to the bottom of the file

<VirtualHost *:80>
 ServerName no-domain
 <Location />
    Order allow,deny
    Deny from all
    Allow from 127.0.0.1
 </Location>
</VirtualHost>

<VirtualHost *:80>
    ServerAlias localhost local.vcap.me
    <Location />
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
    </Location>
</VirtualHost>

<VirtualHost *:80>
    ServerAlias *..vcap.me
    VirtualDocumentRoot "C:/xampp/htdocs/%2/%1"
</VirtualHost>

<VirtualHost *:80>
    ServerAlias *.vcap.me
    VirtualDocumentRoot "C:/xampp/htdocs/%1"
</VirtualHost>

No comments:

Post a Comment