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

1 Answer 1

up vote 2 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

127.0.0.1 foobar

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

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

You may also have to add another virtual host

<VirtualHost *:80>
    DocumentRoot path/to
    ServerName localhost
ServerAlias 127.0.0.*
</VirtualHost>
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
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. –  Markus Bruckner Feb 18 at 10:36

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.