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 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?

share|improve this question
up vote 5 down vote accepted

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.*
share|improve this answer
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
@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. – Markus Bruckner Feb 18 '14 at 10:36

You must log in to answer this question.

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