How to setup local domain names or fake domain names.
HOW TO SETUP LOCAL DOMAIN NAMES OR FAKE DOMAIN NAMES
If you're wanting to develop multiple websites on your host computer (the one XAMPP is installed and running on), then this tutorial will explain how to do it. Do note however this will ONLY work on your host PC and they won't be accessible on any other computer including others connected to your LAN.
You can however later replace the fake local domain names with actual domains you own at a later point. This is a good option if you wish to develop multiple sites offline before going public.
Ok, let's get started.
1.) Go to C:/Windows/System32/drivers/etc/ and open hosts with Notepad.
Now find the entries that look like this:
127.0.0.1 localhost
::1 localhost
2.) Now add your entries just below it like this:
127.0.0.1 localhost
::1 localhost
127.0.0.1 website1
127.0.0.1 website2
127.0.0.1 forum.website2
You can keep adding as many entries as you like. You can name them whatever you like. You can even name them actual domains. However, you will not be able to visit the real domain until the entry is removed and no one else can visit it on your PC.
Once you're finished, simply save the file and close it.
3.) Next go to /xampp/apache/conf/ and open httpd.conf.
Find Include conf/extra/httpd-vhosts.conf and make sure it's not commented out with a ";" or "#" in front of it. If changes need to be made, save it then close it.
4.) Now go to /xampp/apache/conf/extra/ and open httpd-vhosts.conf.
You can make a backup copy of this file if you like. To make this file easier to edit and read, I recommend deleting everything in it, then copy/paste the following and make corrections as needed.
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/xampp/htdocs"
</VirtualHost>
## My First Domain ##
<VirtualHost *:80>
ServerName website1
DocumentRoot "C:/xampp/website1folder/"
<Directory "C:/xampp/website1folder">
Options +Indexes FollowSymLinks +ExecCGI
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
## MY SECOND DOMAIN ##
<VirtualHost *:80>
ServerName website2
DocumentRoot "G:/website2folder/"
<Directory "G:/website2folder">
Options +Indexes FollowSymLinks +ExecCGI
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName forum.website2
DocumentRoot "G:/website2folder/forum/"
<Directory "G:/website2folder/forum">
Options +Indexes FollowSymLinks +ExecCGI
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Now save this file and restart Apache. Assuming you have content in the specified folders, you can type the fake domain names in your browser and it should take you to the folders you specified in httpd-vhosts.conf.
I also wanted to point out a couple of things about the VirtualHost entries I made above.
The lines like ## My First Domain ## are completely optional. The "#" sign makes this line a comment line, so it is only for my own reference. I added these to help me quickly find my entries and keep organized.
In the second domain entry, you can see where I changed the directory to a completely different drive and folder than where I installed XAMPP. You can do this if you want your domain to be in a completely different location.
Now you notice the last entry is listed as a subdomain. This is a great way to make easy domains directly to blogs and forums on a website. And like above, you can have this folder anywhere on your computer as well.
Now I want to make one additional note about these entries I've listed as an example. There's one line that needs to be added if you use my example when you decide to add a real domain. It's the alias line shown here:
<VirtualHost *:80>
ServerName mydomainname.com
ServerAlias www.mydomainname.com
DocumentRoot "G:/mydomain/"
<Directory "G:/mydomain">
Options +Indexes FollowSymLinks +ExecCGI
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
This allows people to reach the correct page if they leave the www off or if they include it, it'll make no difference.
The text between the <Directory "G:/mydomain"> and </Directory> tags are to assign permissions to the directory and it's contents. For more on these settings, go to http://httpd.apache.org/docs/2.2/mod/quickreference.html.
** Closing Notes **
When you get ready to make your website(s) public, make sure you remove any fake domains from your host file if you used real domain names to prevent confusion.
I have two articles that will help you make your website public when you get ready:
How to setup a public domain name
Last Updated (Wednesday, 21 January 2009 03:50)






