Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have seen in many developer talks, the presenter using a demo.local URL instead of the conventional localhost/demo for faster access.

I've read about editing host entries over here How can I create shorter URLs to sites on my computer? but my question is since the localhost IP is the same 127.0.0.1 for every folder inside my var/www or htdocs then how to make it accessible in the shorter format?

share|improve this question
1  
> the presenter using a demo.local URL instead of the conventional localhost/demo for faster access. No idea what you are saying. How exactly is it faster? o.O If anything, it seems like they are simply using a cutesy way of making it look more like a traditional URL with a dot it in. –  Synetech Jul 10 '12 at 1:55

2 Answers 2

up vote 1 down vote accepted

You can edit your /etc/hosts file and add in a line like

127.0.0.1 www.website.com

or

127.0.0.1 demo.local

It would only be accessible via that computer using that domain name.

If you're on windows then you can edit the file below and do similar.

c:\windows\system32\drivers\etc\hosts

You would configure your webhost server so that the demo.local name points to the /demo directory. you could create a hosts translation for example.local and have the webhost server point example.local to the /example directory.

<VirtualHost *:80>
   DocumentRoot /var/www/example
   ServerName example.local
   ServerAlias example.local
</VirtualHost>

<VirtualHost *:80>
   DocumentRoot /var/www/demo
   ServerName demo.local
   ServerAlias demo.local
</VirtualHost>
share|improve this answer
    
That doesn't answer my question.In this case demo.local will point only to the localhost directory whereas I want it to be pointed at localhost/demo/ specific directory.Does this make it clear? –  Ashwini Jul 10 '12 at 0:15
    
::Edit:: Adjusted the answer to fit your issue. Your question didn't sound like it was wanting/cared about direct links for subfolders. –  kobaltz Jul 10 '12 at 1:54

The first step is to make sure the server is configured to accept the desired requests. You can tell the server to host multiple websites, each with their own domain name. Each site can also have its own web root defined. This is where virtual directories (IIS) or vhosts (apache) come in:

http://learn.iis.net/page.aspx/150/understanding-sites-applications-and-virtual-directories-on-iis/

Then you need to have the clients be able to resolve the address you're server is listening for - the hosts file method kobaltz posted in his answer will work fine (though you'll have to open notepad as administrator in order to edit the hosts file).

Alternativly you would configure it in an internal DNS server and you won't have to play with the hosts file on multiple clients.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.