With the help of this tutorial you can assign a virtual domain name to your localhost.
You can access your local website with your favourite name like http://mysite.web instead of http://localhost and also you can assign different virtual domain names to different local webistes.
2. You'll see "127.0.0.1 localhost" at the end of the file.
In the next line add your virtual domain name like the example shown below.
Here mysite.web is just my example. You can use anything you like.
127.0.0.1 mysite.web #this is virtual domain name.
3. Now save the hosts file. mysite.web is just an example. You can add anything like mywebsite.local and you can use any extension or no extension at all.
You can simply add mysite also.
4. Now test your virtual domain. Just type "http://mysite.web" You must see your wamp page or webservers defalut page. If not go through the process again.
NOTE: Don't use any real domain name like www.google.com or your own domain name if you have any. If you did so, you cannot that access the original remote site. This is because, 127.0.0.1 is loopback address, anything with that address will never leave your computer.
1. Open your httpd.conf file in conf directory of Apache webserver folder.
If you are using WAMP click on WAMP icon, go to Apache menu and select httpd.conf there.

2. Create a new folder mysite in your C:\>. And create a new page index.html. These are for testing purposes.
If you have a local website, specify the full path of website in below code.
3. Now add the following code at the end of the httpd.conf file.
NOTE: PLEASE TYPE IN THE CODE MANUALLY without comments, DON'T COPY AND PASTE.
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
ServerName localhost
DocumentRoot "C:/wamp/www" #this is default wamp root for websites,
</VirtualHost>
<VirtualHost 127.0.0.1>
ServerName mysite.web #your virtual domain name
DocumentRoot "C:/mysite" #location of your site, no extenison needed.
<Directory C:/mysite> #again location of your website
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
Save this file. Restart your WAMP server. Now type http://mysite.web You'll see the index page of mysite.
And then copy and paste the following code at the end of httpd.conf file. Just change the virtual domain name, and locations of website.
<VirtualHost 127.0.0.1> ServerName mywebsite.web #change this virtual domain name DocumentRoot "C:/mywebsite" #location of your site, change this. <Directory C:/mywebsite> #again location of your website, change this Order Allow,Deny Allow from all </Directory> </VirtualHost>
You can add as many websites as you wish. Just repeat the above procedure. And access all your local websites with your favorite name. It will be fun and will save lot of your time.
Post new comment