Rewriting URLs

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Rewriting URLs

Postby globex » 18. September 2011 21:38

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.
globex
 
Posts: 8
Joined: 17. October 2009 21:26

Re: Rewriting URLs

Postby glitzi85 » 18. September 2011 21:44

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
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim

Re: Rewriting URLs

Postby globex » 18. September 2011 21:58

Brilliant. Thank you!
globex
 
Posts: 8
Joined: 17. October 2009 21:26


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 121 guests