Search This Blog

Monday, March 23, 2015

How to create a single or multiple local web host domain name using XAMPP running on Windows

Creating multiple local web host domain name with XAMPP running

Are you thinking to run your web site from your home pc using a custom domain (fake domain) name (eg. instead of XAMPP ’s default URL like (http://localhost/my-site or something like that) or want to run multiple web sites from your home pc?

First of all I assure you that it is possible and quite easy. I assume you have installed XAMPP. Installing XAMPP allows you to develop, test, and play around with web server code on your local machine. You can configure and test out your website locally, instead of live somewhere on the web.

In my case, I've used

  • XAMPP 3.2.1
  • windows 7 64 bits
  • Firefox 32.0.2
  • I've installed XAMPP in E:\Installed\Xamp location.

By default XAMPP run your site from a default directory named htdocs. But you can changes this behavior of XAMPP by configuring Apache Server in XAMPP and windows hosts file.

This is a two step process: first, you have to redirect the web site name to your computer; next, you get Apache to redirect the web site address to a specific directory of your choice.

You may know that when we type a web site name into the URL field (eg., our browser sends the name to a Domain Name Server which actually convert the text name to ip address eg. to10.11.201.71 (for example) then connects to IP address Before doing that, it first checks a file called hosts on your computer. If the requested web site name is found, it uses the IP address found in the file. So first we will tell our browser to get our own (local) ip by changing the file host file. This file location is C:\Windows\System32\drivers\etc

Step 1. Configuring the windows’ hosts file

Open the file in any text editor. Go to the bottom of the file. You will find something like below image

Add your custom domain name below these line as in the below image. You can add as many domain names as you wish. See all are the same IP address

Now save the file. Step 1 is done.

Step 2: configuring apache server’s virtual host file

Locate the “httpd-vhosts.conf” virtual host file. File location is in your XAMPP installation drive(c):\XAMPP \apache\conf\extra (in my case it is E:\Installed\Xamp\apache\conf\extra)
Open the file in a text editor and at the bottom of the file add this code by changing ServerName, ServerAlias,DocumentRoot as your needs.

<VirtualHost *:80>
     DocumentRoot E:/Installed/Xamp/htdocs/hiracave

     <Directory "E:/Installed/Xamp/htdocs/hiracave">
        Order allow,deny
        Allow from all

Remember if you have more than one site you need multiple copy of the code. See the bellow image for two website &; I’ve added two piece of the code.

Windows virtual host file


following this label, add the name of the domain you added in windows hosts file.


following this label, you may add the name without “www.” So that you can access your site using or only


following this label, add the path where your website is located.


This portion actually granting permission to access the directory you using. Otherwise you may encounter an ERROR 403

Save the file.

Restart the Apache Server to have the change take effect. Do this by clicking on the Stop button on the XAMPP control panel and then clicking on the Start button.

You are done. Now access your site using your domain name which you have setup just now. Your URL is In my case it is and also I can access my site using and

Thank You…

I hope it will help you to understand how to create a single or multiple local web host domain name using XAMPP
If you have any query\comment please leave it in comment box. I'll be very pleased to reply you. Thank you.

No comments:

Post a Comment

Thank you for your valuable comments!