Php – How to include PHP file from a Virtual Directory on IIS

iisiis-7.5PHPserver-side-includes

I would like to know if there is a way to include PHP files from Virtual Directory to a PHP file in site's root.

For example I have siteroot:

  • siteroot\index.php
  • siteroot\other.php

and a separate userconfig dir, containing client's individual config (and uploads):

  • userconfig\client1\config.php
  • userconfig\client2\config.php
  • userconfig\client3\config.php

I have added IIS site for each client, and a virtual directory within that site pointing to userconfig\clientid\ as "\userconfig\" dir, so each site looks like this:

  • siteroot\index.php
  • siteroot\other.php
  • siteroot\userconfig\config.php

It all works fine, except that I cannot include \userconfig\config.php inside index.php

Any suggestions?


It's IIS 7.5, Windows Server 2008 R2

Best Answer

AFAIK, there is no way to get PHP to do that.

What you probably have to do is simply adjust your PHP application to operate similar to how Drupal ond some other PHP apps work. Various configs are placed in a directory structure like so.

/config/all
/config/blah.example.org
/config/example.org

Basically the PHP application will look at the FQDN the incoming request intended for, then it will try to load a config for that, and then it will try less-specific locations until it selects the default all-sites config.

Related Topic