Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer
    
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... –  Alph.Dev 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.