0

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.

treeface
  • 101
  • 3
  • Wording slightly different, but the same way: http://serverfault.com/questions/96290/how-can-i-set-up-a-local-host-with-a-reasonable-name-different-than-localhost8 http://serverfault.com/questions/189474/apache-on-localhost-give-virtual-hosts-specific-servers-name/189476#189476 – random May 27 '11 at 04:10

1 Answers1

0

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.

treeface
  • 101
  • 3