How2Lab Logo
tech guide & how tos..

How to setup multiple websites in XAMPP

By default XAMPP is setup to run at http://localhost and serve pages that are kept under C:/xampp/htdocs. In this situation, if you want to develop multiple websites, you will need to create a folder under C:/xampp/htdocs for each website and keep the website files thereunder. For example, for a website, you may create a folder such as C:/xampp/htdocs/xyz as the root folder for and then during development, access it with URL http://localhost/xyz/. Likewise, for another website, you will create C:/xampp/htdocs/abc as the root folder and access it with URL http://localhost/abc/.

This is not a very nice way of working with multiple websites on your XAMPP. You would rather prefer to replicate the exact situation as if was hosted on an internet server and access it with URL

How to achieve this?

With a little extra effort, you can configure your XAMPP in such a way so that you can access with URL and with URL To achieve this, you need to setup multiple virtual hosts under XAMPP.

To explain the concept and the method, we will take the example of website The steps to achieve this are as follows:

Step 1. Create a folder for

Create a folder C:/xampp/htdocs/ Now, we will setup public_html as the root folder for the website of so that when you access, the Apache web server will serve page from this public_html folder.

Step 2. Create a virtual host under Apache web server

Navigate to the folder C:/xampp/apache/conf/extra. Open the file httpd-vhosts.conf in a text editor. At the bottom of this file insert the below lines of code/directives.

 DocumentRoot "c:/xampp/htdocs/"

Now restart Apache, i.e. Stop and Start.

Note that you can have multiple entries of the above lines of code, one for each website that you add under your XAMPP.

Step 3. Local DNS Setup

Next, you need to tell your Windows OS, to which IP address it should resolve the domain name or Since is hosted locally, it should resolve to the localhost IP, viz. To achieve this, navigate to C:/Windows/System32/drivers/etc/ folder and open the hosts file in a text editor. At the bottom of the hosts file, add the below line of code.

Now you are all set to start building your website for locally while remaining offline.

After you have completely built your website and tested it thoroughly and then deployed it on an internet server, just comment the above line of code (as shown below).


Once commented, will no more resolve to the local IP Instead, it will resolve to the actual IP of the internet server where has been eventually deployed. Every time you need to do local development on, you can switch back to local mode by un-commenting the code.

Buy Domain & Hosting from a trusted company
Web Services Worldwide | Hostinger
About the Author
Rajeev Kumar
CEO, Computer Solutions
Jamshedpur, India

Rajeev Kumar is the primary author of How2Lab. He is a B.Tech. from IIT Kanpur with several years of experience in IT education and Software development. He has taught a wide spectrum of people including fresh young talents, students of premier engineering colleges & management institutes, and IT professionals.

Rajeev has founded Computer Solutions & Web Services Worldwide. He has hands-on experience of building variety of websites and business applications, that include - SaaS based erp & e-commerce systems, and cloud deployed operations management software for health-care, manufacturing and other industries.

Refer a friendSitemapDisclaimerPrivacy
Copyright © All rights reserved.