Skip to content

Instantly share code, notes, and snippets.

@shrwnsan
Created April 23, 2013 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shrwnsan/5444567 to your computer and use it in GitHub Desktop.
Save shrwnsan/5444567 to your computer and use it in GitHub Desktop.
Proper DOCUMENT_ROOT when using mod_vhost_alias. Source http://jbenner.net/blog/quick-tip-get-proper-document-root-when-using-mod-vhost-alias
// Note: httpd-vhosts.conf filename just used as an example.
// Add the following line to your apache configuration inside the VirtualDocumentRoot vhost definition
// E.g.
// <VirtualHost *:80>
// ...
// {paste here}
// </VirtualHost>
php_admin_value auto_prepend_file "/Users/USERNAME/Sites/setdocroot.php"
<?php
apache_setenv("DOCUMENT_ROOT",
$_SERVER['DOCUMENT_ROOT'] = str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['SCRIPT_FILENAME'])
);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment