How to Set Up a Local Virtual Host with XAMPP on Windows

This guide explains step by step how to create a local Virtual Host in XAMPP on Windows so you can use custom domains like http://myproject.local for your development environment.

  1. 1. Open Apache Virtual Hosts Config

    Go to your XAMPP installation folder and open:

    C:\xampp\apache\conf\extra\httpd-vhosts.conf

    Edit the file with Notepad++ or another editor as Administrator.

  2. 2. Add a Virtual Host

    At the bottom of the file, insert:

    <VirtualHost *:80>
        ServerName myproject.local
        DocumentRoot "C:/xampp/htdocs/myproject"
        <Directory "C:/xampp/htdocs/myproject">
            Options Indexes FollowSymLinks Includes ExecCGI
            AllowOverride All
            Require all granted
        </Directory>
    </VirtualHost>
    

    Replace myproject.local with your custom domain and set the correct project folder path.

  3. 3. Enable Virtual Hosts in Apache

    Open the main Apache config file:

    C:\xampp\apache\conf\httpd.conf

    Make sure this line is uncommented (remove the # if present):

    Include conf/extra/httpd-vhosts.conf
  4. 4. Edit Windows Hosts File

    To map your custom domain to localhost, edit:

    C:\Windows\System32\drivers\etc\hosts

    Add this line at the bottom:

    127.0.0.1   myproject.local

    Save the file with Administrator rights.

  5. 5. Restart Apache

    Open XAMPP Control Panel → Stop Apache → Start Apache again.

  6. 6. Test Your Local Domain

    Open a browser and go to:

    http://myproject.local

    You should now see your project running from C:/xampp/htdocs/myproject.

🎉 Done! You have successfully configured a Virtual Host in XAMPP on Windows and can now develop using a clean local domain.

Tagged: , , , , , , , , ,

Written by David

Leave a Comment

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