Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 know this has probably been asked a million times, but I think I'm just not phrasing the question correctly. I'm running Win7 with XAMPP (apache) and I currently go here in my browser to navigate to a site on localhost:


But I want to be able to end up in the same place by go to this address:


The htdocs folder is in a subdirectory for security purposes, and the way I have it right now, all the references to, for example, /js/main.js are pointing at http://localhost/js instead of http://localhost/client/htdocs/js where it should be.

Thanks guys.

share|improve this question
Wording slightly different, but the same way:…… – random May 27 '11 at 4:10
up vote 0 down vote accepted

Alright so this is how it's done.

Go to C:\xampp\apache\conf\extra\httpd-vhosts.conf and add this:


   DocumentRoot "C:\xampp\htdocs\client\htdocs"
   ServerName client

The server name can be could even make it (but then you would lose access to the real Before closing that file, add this to ensure that localhost also still works:

   DocumentRoot C:\xampp\htdocs
   ServerName localhost

Then go to C:\Windows\System32\drivers\etc\hosts and add this to the end: client

Where client is whatever you put for ServerName above. Save and close (you might need to run notepad as an administrator to save this file. If you right click on notepad and "run as administrator" then open the file using file->open, you can do that.

Restart Apache and navigate to http://client in your browser. It should point at that directory now.

Hope this helped someone.

share|improve this answer

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.