I am running Xampp on a Windows 7 machine. I have a website that is running off a directory in my web root. I access the website by going to http://localhost/foobar.

I would like to set it up so that I can point my local browser to say, http://foobar, and have it treat the foobar directory like the web root directory.

Is that a matter of changing the hosts file or configuration on apache?


To get your browser to look for http://foobar on your local machine you'll have to add this line to your host file foobar

Then add a virtual host in your Apache http.conf file,

<VirtualHost *:80>
    DocumentRoot path/to/foobar
    ServerName foobar

You may also have to add another virtual host

<VirtualHost *:80>
    DocumentRoot path/to
    ServerName localhost
ServerAlias 127.0.0.*
  • Thanks, Musa, that worked great! The ServerAlias part was not necessary.
    – Evil E
    Nov 13 '12 at 15:51
  • Some additional info, with xampp the http.conf included the file httpd-vhosts.conf, which is where I made my changes. I also had to uncomment the line NameVirtualHost *:80 to get it to work.
    – Evil E
    Nov 13 '12 at 16:14
  • I get: Access forbidden! You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
    – Talon
    Jul 26 '13 at 18:19
  • 1
    @Talon Make sure Apache (or whatever server you are using) has access to the directory. For example, storing the data in your user directory C:\users\... might be problematic. Feb 18 '14 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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