This is a small script that facilitates the configuration of virtual hostings in xamp on windows.
All confgurations will be saved in the Config.ini file in the same folder as the script.
If this file does not exist, the script will try to create it dynamically.
The first time the script is run, it will attempts to locate the configuration file to load the initial settings.
If not found it will try to create it dynamically with the help of the user.
- XAMPPDIR: The installation path of Xampp | Defautl: C:\xammp
- BASEURL: The document root for Xampp | Default: C:\xammp\htdocs\
- PREFIX: The prefix for the virtual host domain | Defualt: dev
- SUFFIX: The suffix for the virtual host domain | Defualt: local
When executed the script prompts the user to complete two values.
-
Domain name: [prefix][domain][local]
Ex.: For the domain dev.mysite.local, just enter the text mysite. -
Path to site root (relative to C:\mysitesfolder).
-
The script will ask the user to confirm the values.
-
And it will save the all the configurations in the appropriate files.
- C:\Windows\System32\drivers\etc\hosts
- C:\xampp\apache\conf\extra\httpd-vhosts.conf
- Now you just have to restart apache for the changes to take effect.
This is an example of the code generated by the script:
-
Domain: dev.mysite.local
-
Virtual Host:
###leandrogarcia###
<VirtualHost *>
DocumentRoot "C:\xampp\htdocs\mysitefiles\"
ServerName dev.mysite.local
<Directory "C:\xampp\htdocs\mysitefiles\">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>