Set a domain as your localhost.




You can use your desired domain instead of using http://localhost,  like as a sample. It will even work even without internet connection.

Here are the simple steps:

1. Install XAMPP in your local computer. You can get it here for free. XAMPP

2. After a successful installation, you need to modify your “hosts” file.

It can be found in these directories:


Edit the “hosts” file with your favorite text editor.

3. Find the following texts: localhost

Add some configuration below on it:

It should now look like this: localhost

4. The next thing to do is to create a directory for your webfiles in the htdocs directory in xampp. Example of a directory name is “rastaval” (without double quotes).

I personally suggest to choose a directory name  for a specific domain.

5. The next thing to do is to explore the following directories:


Find edit httpd-vhosts.conf with your text editor.

6. Find #NameVirtualHost *:80:

Remove # to uncomment the line.

7. Create a virtual host. As what I did on my configuration with the domain in my localhost, it looked like this:

<VirtualHost *:80>
DocumentRoot “C:/xampp/htdocs/rastaval”

<VirtualHost *:80>
DocumentRoot “C:/xampp/htdocs/rastaval”

NOTE:* Be sure everyline of the configuration is not commented or prefixed with #.
Be sure you have created separately for the with www and non-www domains.

8. To check if it is working, create a file and save it as index.php

Edit index.php and enter this simple php function:

$host = $_SERVER[‘HTTP_HOST’];

<h1 style=”text-align:center;”>
PHP configuration of <?php echo $host; ?></h1>


Save it and it should be placed inside the rastaval directory to make it as a starting page for our domain

9. Now, run your XAMPP Control Panel, and tick Svc and Click the corresponding Start button for Apache. If you wish to use a database for your site, then you need to run MySQL as well. Ticking Svc means, the application will run as a service and everytime your computer starts, XAMPP will automatically run.

10. Open your favorite web browser, and I recommend Firefox, Flock or Google Chrome to use as your default web browser.
Type in the address bar,


11. And you’re done. If you wish to create more domains in your localhost, you can just repeat the procedure. Happy Hosting 😀