Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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:

http://localhost/client/htdocs

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

http://client

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: serverfault.com/questions/96290/… serverfault.com/questions/189474/… –  random May 27 '11 at 4:10
add comment

1 Answer

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:

NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>
   DocumentRoot "C:\xampp\htdocs\client\htdocs"
   ServerName client
</VirtualHost>

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

<VirtualHost 127.0.0.1>
   DocumentRoot C:\xampp\htdocs
   ServerName localhost
</VirtualHost>

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

127.0.0.1 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
add comment

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.