How To Replace Localhost With Own Domain In Local Server
Before I start this tips and trick, authors need to explain the means used in this exercise.
In this exercise the author Using Windows XP and XAMPP
Most people run the files on their website using the localhost or http://localhost http://127.0.0.1. Maybe some of you already know that localhost can be replaced with your domain name (http://yourdomain.com) only by adding these lines to the file 127.0.0.1 yourdomain.com hosts that are in the folder C:\WINDOWS\system32\drivers\etc, then you can run the domainname as you see fit.
Example of writing:
127.0.0.1 localhost
127.0.0.1 yourdomain.com
Here the author will give a few tips how to run http://localhost and http://yourdomain.com with a different web page with the help of VirtualHost. So you can manage all, or to create a virtual website (backup site) on Your Computer.
Now Let’s Get Rock:-P
First Step
Set the file folder of your website for a Domain in the folder “C:\xampp\htdocs” or “D: \WEB\www” switch if you have data in the D Drive.
Illustration
For example you have the joomla and wordpress site with each domain name http://myjoomlasite.com http://mywordpress.com and then create a folder in C:\xampp\htdocs\myjoomlasite.com with the name and mywordpress.com
Note:
Each script joomla and wordpress already myjoomlasite.com and in folder mywordpress.com.The second step
Now open the host file in the folder C:\WINDOWS\system32\drivers\etc and add 127.0.0.1 myjoomlasite.com and 127.0.0.1 mywordpress.com right under 127.0.0.1 localhost.
See examples written:
127.0.0.1 localhost
127.0.0.1 myjoomlasite.com
127.0.0.1 mywordpress.com
Step three
Activate VirtualHost for each domain, I open the file httpd-vhosts.conf in the folder C:\xampp\apache\conf\extra and then on the last line add:
NameVirtualHost localhost:80
<VirtualHost localhost:80>
ServerAdmin webmaster@localhost
DocumentRoot “C:/xampp/htdocs”
ServerName localhost
</VirtualHost>
NameVirtualHost myjoomlasite.com:80
<VirtualHost myjoomlasite.com:80>
ServerAdmin webmaster@myjoomlasite.com
DocumentRoot “C:/xampp/htdocs/myjoomlasite.com”
ServerName myjoomlasite.com
</VirtualHost>
NameVirtualHost mywordpress.com:80
<VirtualHost mywordpress.com:80>
ServerAdmin webmaster@mywordpress.com
DocumentRoot “C:/xampp/htdocs/mywordpress.com”
ServerName mywordpress.com
</VirtualHost>
After that you restart Apache (Start>> Settings>> Control Panel>> Administrative Tools>> Services)