Search code examples
apachexampplocaldocument-root

XAMPP server document root for specific website


I just installed XAMPP, and I've found how to change the document root in the Apache config file, but I only want to change it for a specific site. The reason I need this is because all of my links are absolute links (i.e. /url not just url).

I tried changing it with .htaccess, but that gave me errors saying the limited recursion had been exceeded. So I went and changed that to 200, and it too a really long time, and then said that the recursion had been exceeded.

I would use aliases, but that would mean saying that any request to / goes somewhere else.

So is there anyway for me to specify that files inside of directory dir should have their document root as dir?

Thanks.


Solution

  • I found the solution, but it's a bit involved. You have to change the Apace config file, and the hosts file.

    In the Apache config file, I added this:

    NameVirtualHost *:80
    <VirtualHost *:80>
     DocumentRoot "/absolute path/from/C/drive"
     ServerName site.local
    </VirtualHost>
    

    Then I had to add this in the hosts file:

    127.0.0.1 site.local
    

    You can read up more on the virtual host here: http://httpd.apache.org/docs/2.2/vhosts/examples.html