A small solution in follow up of the document root issue drm brought up in a previous post. Setting the correct $_SERVER["document_root"] value for your vhost_alias site.
The problem is a long ago confirmed yet still not solved bug in apache mod_vhost_alias, however with a little PHP magic it was easy fixable in my local XAMPP configuration using the php_admin_value directive in the vhost configuration.
Step 1
Open the httpd_vhosts.conf located in the /Applictions/XAMPP/etc/extra folder and add the following line to the virtual_host definition
php_admin_value auto_prepend_file /Applications/XAMPP/xamppfiles/lib/php/fix_docroot.php
So I ended up with a httpd_vhost configuration looking like this :
<VirtualHost *:80> ServerName dev.local ServerAlias *.dev.local ServerAdmin webmaster@localhost VirtualDocumentRoot "/Users/rene/Sites/%1" VirtualDocumentRoot "/Users/rene/Sites/%-3+/" <Directory /Users/rene/Sites/> Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> php_admin_value auto_prepend_file /Applications/XAMPP/xamppfiles/lib/php/fix_docroot.php </Virtualhost>
Step 2
Next up is creating a small php str_replace function in fix_docroot.php , which is loaded and executed at every request.
Open up your favorite code editor, and create a file called fix_docroot.php at /Applications/XAMPP/xamppfiles/lib/php/ and paste the following chunk of code in it.
<?php $_SERVER["ORG_DOCUMENT_ROOT"] = $_SERVER["DOCUMENT_ROOT"]; $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["SCRIPT_NAME"], '',$_SERVER["SCRIPT_FILENAME"]); ?>
Save it, restart apache and the values should be set correctly, with the old value still available in $_SERVER["ORG_DOCUMENT_ROOT"] just in case it is needed for something.