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.

1

1 Answer 1

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.

You must log in to answer this question.

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