- 1 year ago
After running https url with virtual host how can add more that one domain in xampp server
To add multiple domains to your XAMPP server, you can follow these steps:
Open the Apache configuration file: Locate and open the
httpd.conf
file in your XAMPP installation directory. The default location for XAMPP on Windows isC:\xampp\apache\conf\httpd.conf
.Create virtual hosts: In the
httpd.conf
file, search for the# Virtual hosts
section. Uncomment the following lines to enable virtual hosts:shell# Include conf/extra/httpd-vhosts.conf
Configure virtual hosts: Open the
httpd-vhosts.conf
file located in theextra
directory within your XAMPP installation directory (C:\xampp\apache\conf\extra\httpd-vhosts.conf
).Define virtual hosts: Inside the
httpd-vhosts.conf
file, you can define your virtual hosts using the<VirtualHost>
directive. Here's an example of a virtual host configuration:apache<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/domain1"
ServerName domain1.test
<Directory "C:/xampp/htdocs/domain1">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/domain2"
ServerName domain2.test
<Directory "C:/xampp/htdocs/domain2">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
In the above example, two virtual hosts are defined:
domain1.test
anddomain2.test
. Make sure to replace theDocumentRoot
andDirectory
paths with the correct paths for your domains.Update hosts file: Open the hosts file located in
C:\Windows\System32\drivers\etc\hosts
(you may need administrator privileges). Add the following lines at the end of the file to map the domain names to the localhost IP address (127.0.0.1):127.0.0.1 domain1.test
127.0.0.1 domain2.test
Restart the Apache server: Save the changes made to the configuration files, and then restart the Apache server in XAMPP.
Test the virtual hosts: Open a web browser and enter the domain names (e.g.,
http://domain1.test
andhttp://domain2.test
) to access the respective virtual hosts.
By following these steps, you can add multiple domains to your XAMPP server and access them using the defined virtual hosts. Remember to ensure that the specified DocumentRoot directories exist and contain the corresponding website files for each domain.