Share icon

To create a virtual host (vhost) using XAMPP, you'll need to follow these steps:

Step 1: Open the Apache configuration file

  1. Locate the httpd-vhosts.conf file in the XAMPP installation directory. By default, it's located at C:\xampp\apache\conf\extra\httpd-vhosts.conf.
  2. Open the file in a text editor.

Step 2: Configure the virtual host

  1. Add the following code at the end of the file to define your virtual host:
    <VirtualHost *:80>
        DocumentRoot "C:/xampp/htdocs/your_project_folder"
        ServerName yourdomain.test
    </VirtualHost>
    

    Replace "C:/xampp/htdocs/your_project_folder" with the actual path to your project folder. This is the directory where your website's files reside. Replace "yourdomain.test" with the desired domain name for your virtual host. You can choose any domain name, but make sure to add it to the hosts file as well (explained in the next step).

Step 3: Modify the hosts file

  1. Open the hosts file on your computer. It's located at C:\Windows\System32\drivers\etc\hosts.
  2. Open the file in a text editor with administrative privileges.
  3. Add the following line at the end of the file:
    127.0.0.1    yourdomain.test
    

    Replace "yourdomain.test" with the same domain name you used in the virtual host configuration.

Step 4: Restart Apache server

  1. Open the XAMPP Control Panel.
  2. Stop the Apache server by clicking the "Stop" button.
  3. Start the Apache server again by clicking the "Start" button.
  4. Open your web browser.
  5. Visit http://yourdomain.test (replace "yourdomain.test" with your chosen domain name).
  6. If everything is set up correctly, you should see your website served from the specified project folder.
  7. That's it! You have successfully created a virtual host using XAMPP. Now you can develop and access your website using the custom domain name you configured.

Step 5: Access your virtual host

Add new comment

Restricted HTML