Page 1 of 1

Rewriting URLs

PostPosted: 18. September 2011 21:38
by globex
I'd like to be able to type "http://test" into my browser and have it map to XAMPP's htdocs/test/ folder. How do I go about doing that?

I can edit the Windows hosts file and point "test" to "localhost", but I can't tell it to go into the test folder.
I can create a VirtualHost in the apache config, but then it rewrites the "localhost" address too, and I can no longer access "http://localhost".

Can someone please offer a solution?

Thank you.

Re: Rewriting URLs

PostPosted: 18. September 2011 21:44
by glitzi85
Hi,

If you create VirtualHosts, the normal Server configuration is disabled an only vHosts are enabled. That means you have to create an additional vHost for localhost.

Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
  ServerName localhost
</VirtualHost>

<VirtualHost *:80>
  ServerName test
  DocumentRoot /xampp/htdocs/test
</VirtualHost>

The only necessary directive in an VirtualHost-Block is ServerName. All other settings are inherited from the global server config (or from default values if not set anywhere).
Please be aware of the fact that every request to your server which is not covered by ServerName or ServerAlias is served by the first found VirtualHost. That is the reason why localhost is pointed to test after your change.

glitzi

Re: Rewriting URLs

PostPosted: 18. September 2011 21:58
by globex
Brilliant. Thank you!