XAMPP Virtual Hosts not working
Follow these steps if you are in windows environment (7 & 10 tested) with XAMPP:
- Add in hosts file [
C:\Windows\System32\drivers\etc
]
127.0.0.1 vws.localhost 127.0.0.1 instancegaming.net 127.0.0.1 vws.instancegaming.net
- Add this in httpd.conf [
C:\__Server\apache\conf
] . though some says there are security risks with this but couldn't find a way without this
<Directory /> AllowOverride none Require all granted </Directory>
- Add these in httpd-vhosts.conf [
C:\__Server\apache\conf\extra
]
<VirtualHost *:80> ServerName localhost DocumentRoot "C:\__Server\htdocs" <Directory "C:\__Server\htdocs"> DirectoryIndex index.php </Directory> </VirtualHost> <VirtualHost *:80> ServerName tools.com.at DocumentRoot "E:\phpStorms\git\tools-class" SetEnv APPLICATION_ENV "development" <Directory "E:\phpStorms\git\tools-class"> DirectoryIndex index.php AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> <VirtualHost *:80> ServerName laravel.test.com.at DocumentRoot "E:\laravel.test.com.at\public" SetEnv APPLICATION_ENV "development" <Directory "E:\laravel.test.com.at\public"> DirectoryIndex index.php AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
template of this
<VirtualHost *:80>
ServerName nameInHostsFile
DocumentRoot "pathOfTheWindowsFileLocationWhichWillBeDocumentRoot"
SetEnv APPLICATION_ENV "development"
<Directory "pathOfTheWindowsFileLocationWhichWillBeDocumentRoot">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Note 1: My xampp installed on C:\__Server
location
Note 2 : My folder name is laravel.test.com.at
and its in E:
drive E:\laravel.test.com.at
Note 3: Always copy folder location from address bar in windows explorer, so there is no mistakes.
Note 4: You must restart XAMPP after editing httpd-vhosts.conf every time.
Note 5: Use uncommon part in url [i.e .com.at] so that it is unique and there is no issue resolving dns.
Update: troubleshoot@Jacob Jewett
After a fresh copy of XAMPP installation in C drive -
- just add/append these line in httpd-vhosts.conf file
<VirtualHost *:80> ServerName localhost DocumentRoot "C:\xampp\htdocs" <Directory "C:\xampp\htdocs"> DirectoryIndex index.php </Directory> </VirtualHost> <VirtualHost *:80> ServerName vws.localhost DocumentRoot "C:\xampp\vws" SetEnv APPLICATION_ENV "development" <Directory "C:\xampp\vws"> DirectoryIndex index.php AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
- Add append this in httpd.conf file
<Directory /> AllowOverride none Require all granted </Directory>
ADD
PATH
variable for php [C:\xampp\php
], and also check that there isn't another php path in thePATH
variable.restart xampp and browse localhost
Additionally make sure that the line
Include etc/extra/httpd-vhosts.conf
is not quoted out in httpd.conf