We are using IP-based VirtualHosts so no need for the NameVirtualHost directive.
First we set the server to listen on port 80 from all IPs.
Then we keep the localhost as the default so you can go to the XAMPP Welcome Page.
Next we add your local access to Moodle.
Then we add your external access to Moodle.
(
I have kept them both in separate VirtualHost containers for ease of trouble shooting)
Try this in your
C:\xampp\apache\conf\extra\httpd_vhosts.conf
- Code: Select all
Listen 80
<VirtualHost 127.0.0.1>
ServerName localhost
DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 172.20.0.113>
ServerName moodle
DocumentRoot "C:/XAMPP/htdocs/moodle"
<Directory "C:/XAMPP/htdocs/moodle" >
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 81.137.43.209>
ServerName moodle
DocumentRoot "C:/XAMPP/htdocs/moodle"
<Directory "C:/XAMPP/htdocs/moodle" >
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Save the file and restart the Apache server.
The Windows hosts file:
- Code: Select all
127.0.0.1 localhost
172.20.0.113 moodle
81.137.43.209 moodle
69.57.152.127 pagead2.googlesyndication.com
You will also have to make sure that your ISP does not block port 80 from external users, some do not allow their clients to run servers.
Make sure that all the ports that XAMPP uses are open to your network.
Internally
http://moodle should work now with the above configuration.
http://81.137.43.209 should work for external access.
http://localhost and
http://127.0.0.1 should work and take you to the XAMPP Welcome Page but only from your PC - others on the network and external users don't have access to localhost loop back addresses on your PC.
The above configuration should be available as soon as you have restarted the Apache server after making the above changes - make sure the
C:\xampp\apache\conf\httpd.conf file is still the XAMPP installation default - no changes in this file since installing XAMPP.
Always make a backup of conf and ini files before making edits so you can revert if things go belly up.