How To create virtual host in xampp windows 7?

To create a virtual host in XAMPP on Windows, follow these steps:

Open the httpd-vhosts.conf file in the Apache configuration directory. You can find this file at C:\xampp\apache\conf\extra\httpd-vhosts.conf. You can open this file in any text editor, such as Notepad.

Uncomment the following line in the httpd-vhosts.conf file by removing the # symbol at the beginning of the line:

#Include conf/extra/httpd-vhosts.conf

Add the following code to the end of the httpd-vhosts.conf file, replacing “example.com” with the name of your virtual host, “C:\xampp\htdocs\example” with the path to the directory containing your virtual host files, and “127.0.0.1” with the IP address of your localhost:


    ServerAdmin [email protected]
    DocumentRoot "C:\xampp\htdocs\example"
    ServerName example.com
    ErrorLog "logs/example.com-error.log"
    CustomLog "logs/example.com-access.log" common
    
        Require all granted
    


Save the httpd-vhosts.conf file and close the text editor.

Open the hosts file located at C:\Windows\System32\drivers\etc\hosts in a text editor with administrator privileges.

Add the following line to the end of the hosts file, replacing “example.com” with the name of your virtual host:

127.0.0.1 example.com

Save the hosts file and close the text editor.

Restart the Apache server in XAMPP.

Open a web browser and navigate to http://example.com. You should see the homepage for your virtual host.

Congratulations, you have successfully created a virtual host in XAMPP on Windows!

Leave a Comment