2

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

Slava
  • 201
  • 3
  • 11

1 Answers1

1

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.

Zoredache
  • 128,755
  • 40
  • 271
  • 413
  • Got it done using hostname as client identifier, like you suggested. `include($_SERVER['DOCUMENT_ROOT'] .'\\'. $_SERVER['HTTP_HOST'] .'\\userconfig\\config.php');`. Thanks. I wonder if there are any security issues related to this approach... – Slava Feb 24 '12 at 23:13
  • I guess it kinda depend on if you can trust $_SERVER while under IIS to have only valid data. – Zoredache Feb 24 '12 at 23:19