Reputation: 613
I am working on two different web development projects say A and B. I put all the project-A files in C:\xampp\htdocs\A and similarly all the project-B files in C:\xampp\htdocs\B. Sometimes I need to work on both the projects without switching work space. I am able to see the websites running on localhost:8080
one at a time. How can I run both websites at same time without switching work space? I would like to access the website A.localhost
and B.localhost
in browser?
I have done some research and found that there is a concept called Virtual Hosts in XAMPP. But not able to implement properly, also I tried the same via this tutorial but the browser displayed dns_unresolved_hostname
issue. Can someone provide exact steps to implement this setup in XAMPP.
This is my project structure:
C:\xampp\htdocs\A - index.html, style.css etc for ProjectA
C:\xampp\htdocs\B - index.html, style.css etc for ProjectB
Upvotes: 1
Views: 3190
Reputation: 1045
For windows
Step: 1
Open this file C:\xampp\apache\conf\extra\httpd-vhosts.conf
with any text editor (administrative privileges not required)
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs\project1\public"
ServerName project1.test
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs\project2\public"
ServerName project2.test
</VirtualHost>
Step: 2
Open this file C:\Windows\System32\drivers\etc\hosts
with any text editor (administrative privileges required)
127.0.0.1 project1.test
127.0.0.1 project2.test
Now restart Xampp
Upvotes: 0
Reputation: 2644
# Setup Listening Port
NameVirtualHost *:8080
# Ensure "localhost" is preserved
<VirtualHost *:8080>
ServerName a.localhost
DocumentRoot "C:\xampp\htdocs"
</VirtualHost>
# Setup "a.localhost" Virtual Host
<VirtualHost *:8080>
ServerName b.localhost
DocumentRoot "C:\xampp\htdocs\B"
<Directory "C:\xampp\htdocs\B">
Options Indexes FollowSymLinks Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
# Setup "a.localhost" Virtual Host
<VirtualHost *:8080>
ServerName a.localhost
DocumentRoot "C:\xampp\htdocs\A"
<Directory "C:\xampp\htdocs\A">
Options Indexes FollowSymLinks Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And open C:\windows\system32\drivers\etc\hosts
Add theses lines at end
127.0.0.1 a.localhost
127.0.0.1 b.localhost
Upvotes: 2