Ask Different is a question and answer site for power users of Apple hardware and software. 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 added two new host entries in

/pricate/etc/hosts local.wys local.les

I have flushed the DNS using

dscacheutil -flushcache

I now want to access local.wys and have content served from


This doesn't work, I have tried and localhost in the hosts file.

Any ideas?

Thanks, Jake

share|improve this question
up vote 1 down vote accepted

A friend of mine provided the answer via email....


The purpose of the hosts file is to serve as a local supplement to a dns lookup (on linux, you can actually specify whether it asks DNS or the file first). As such, it is only used to return IP addresses. You need to use this in combination with Apache VirtualHosts to make apache respond to a host using a specific directory.

So... you hosts file should look like local.wys local.les

Find your apache configuration directory. Under XAMPP this is c:\xampp\apache\conf (yours might be ‘conf.d’) In conf you’ll have a folder called ‘extra’ and it that a file called ‘http-vhosts.conf’. Open that file.

Make sure that the following line is uncommented

NameVirtualHost *:80

You’ll need a default entry, and then any specific ones for each hostname you want to use.

The default one...

<VirtualHost *:80>
    ServerAdmin technical@satellite   
    DocumentRoot "c:/webroot"
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" combined

The custom ones should look like this, replace ‘airbase.local’ with ‘local.wys’ and the value of document root to where you want it to start serving files from.

<VirtualHost *:80>
    ServerName airbase.local
    ServerAdmin technical@satellite
    DocumentRoot "D:/webroot/airbase/magento"
    ErrorLog "logs/airbase-error.log"
    CustomLog "logs/airbase-access.log" combined

Restart apache and it should all be working nicely!

share|improve this answer
c:\xampp\apache\conf? As in c:, the windows partition? Also who uses XAMPP? Apache is already installed on OS X. – XQYZ Jun 4 '11 at 12:23
Regardless, MAMP, XAMPP, it is Apache that needs to be restarted. You have omitted a portion of the answer to fit your negative comment, the full line is c:\xampp\apache\conf (yours might be ‘conf.d’) – Jake N Jun 4 '11 at 15:43

Your Answer


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.