Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 for every folder inside my var/www or htdocs then how to make it accessible in the shorter format?

share|improve this question
> 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
up vote 1 down vote accepted

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

or 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.


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 *:80>
   DocumentRoot /var/www/demo
   ServerName demo.local
   ServerAlias demo.local
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:

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .