dealing with VirtualHosts in XAMPP

If the URL schema of http://localhost/foldername isn’t working for you, or you just want to test the webpages behavior with the live address, you need to configure so called VirtualHosts in Apache. Usually that is done by editing httpd.conf but XAMPP has a different (and much easier) approach to this. Let’s take a look!

First you want to navigate to \apache\conf\extra inside your XAMPP’s install directory, and look for a file named httpd-vhosts.conf:


Open it in a text editor of your liking. Notice that everything is commented out, let’s just leave it as it is, and insert the following lines at the end of it:

    DocumentRoot "C:\xampp\htdocs\miniCRM"
    ServerName miniCRM.local
    ServerAlias www.miniCRM.local
    <Directory "C:\xampp\htdocs\miniCRM">
        Order allow,deny
        Allow from all


  • I’m using miniCRM for this example and all folders are named as such. You need to change miniCRM in all the examples shown here to your-folder-name
  • I’m using .local as the top-level domain, but can you can use anything you want for example: .com, .org depending on your needs.

So the file should look something like this:


Now we need to restart Apache. From the XAMPP control panel Stop Apache:


And the Start it again:


It should start:


We need to edit one more file for the name resolution to work. If you have UAC enabled you want to start the text editor in elevated mode (Run as Administrator) as shown below:


Open the file named hostsĀ located underĀ \System32\drivers\etc of your Windows directory:


You can tweak name resolution from within this file. To do that, you can enter an IP Address (or range) DNS name pair separated by a space (or tab) per line. Here is an example: miniCRM.local

This for example will bind the name miniCRM.local to (which is the localhost’s IP Address). You can use any kind of domain name (even external ones) here, as this file will be parsed before the DNS servers. Here is how it should look like:


Save the file and you should be able to reach the address locally:


Leave a Reply

Your email address will not be published. Required fields are marked *