Skip to content

Instantly share code, notes, and snippets.

@mtvbrianking
Last active November 4, 2019 06:59
Show Gist options
  • Save mtvbrianking/f149033d8594aed9a96f711ff3efe047 to your computer and use it in GitHub Desktop.
Save mtvbrianking/f149033d8594aed9a96f711ff3efe047 to your computer and use it in GitHub Desktop.
Windows Xampp vHosts

WINDOWS XAMPP VHOSTS

Enable vHosts

Uncommenting the following line in C:\xampp\apache\conf\httpd.conf

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

Create a vHost

*Note:

  • Apache should be running on the default port 80
  • Avoid the .dev extension.
C:\xampp\apache\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/espire.local"
    ServerName espire.local
    ErrorLog "logs/espire.local-error.log"
    CustomLog "logs/espire.local-access.log" combined
    <Directory "C:/xampp/htdocs/espire.local">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/cis.local/public"
    ServerName cis.local
    ErrorLog "logs/cis.local-error.log"
    CustomLog "logs/cis.local-access.log" combined
    <Directory "C:/xampp/htdocs/cis.local/public">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/api.cis.local/public"
    ServerName api.cis.local
    ErrorLog "logs/api.cis.local-error.log"
    CustomLog "logs/api.cis.local-access.log" combined
    <Directory "C:/xampp/htdocs/api.cis.local/public">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Register vHost

* Note:

  • File has to be edited with Administrator rights. Open Note as admin, then Ctrl+O the file
C:\Windows\System32\drivers\etc\hosts
127.0.0.1      cis.local
127.0.0.1      espire.local
127.0.0.1      api.cis.local

Restart Apache Web Server

From the XAMPP Control Panel

Test

http://cis.local

http://espire.local

http://api.cis.local

Source:

https://ultimatefosters.com/hosting/setup-a-virtual-host-in-windows-with-xampp-server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment