Configuring subdomains and virtual hosts
Creating a host
Open the folder where XAMPP is installed, usually “C:\XAMPP\”, then go to the directory “apache\conf\extra” and open the file httpd-vhosts.conf. In it you will see commented (##) lines wrapped in VirtualHost – these are examples of host settings.
After these lines, you need to add lines with the required configurations, here is an example of configuring the modx3.com host (and a separate locahost):
<VirtualHost *:80>
DocumentRoot "E:/xampp/htdocs"
ServerName locahost
ServerAlias locahost
ErrorLog "logs/localhost.log"
CustomLog "logs/localhost.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "E:/xampp/htdocs/modx3.com"
ServerName modx3.com
ServerAlias modx3.com
ErrorLog "logs/modx3.com.log"
CustomLog "logs/modx3.com.log" common
</VirtualHost>
Result screenshot:
This configuration leaves localhost activated and adds a new host modx3.com (this is the folder where we installed the CMS).
Well, for the new host to work, you need to add it to the hosts file.
Editing the hosts file
Go to the directory: C:\Windows\System32\drivers\etc
Open the hosts file
Add the line at the end of the file: 127.0.0.1 modx3.com and save it.
Save all files with the changes you made. Restart Apache (stop and start) in the xampp control panel.
Open the browser and enter the modx3.com domain in the URL bar – if the project has an index file (index.html or index.php), it should load.
Additional information
The article provides examples with a local host/domain modx3.com and the path to the project folder – modx3.com.
If you are setting up xampp for yourself, you need to replace the domain name modx3.com and the path to the project modx3.com with your own.