I really hoped that this day would never come, but I've been charged with setting up PHP5 on the dreaded Microsoft IIS Web server.

Everything went pretty smooth with one exception: relative file includes are not working... at all.

Suppose the directory structure is like this:
/ (this is the root of the site and is located at D:\mysite)
/includes

If I create a PHP file at the root of the IIS site, this works:

include_once('D:\mysite\includes\include.inc.php');

But if I try this, it fails:

include_once('includes/include.inc.php');
//This fails, too:
//include_once('./includes/include.inc.php');

It's like IIS is incorrectly composing the relative path locations. Has anyone run into this problem before? I found several similar posts, but not a one had any kind of acceptable answer.

Thanks!

* EDIT *

I just discovered that this issue ONLY occurs when I change my site's root folder from IIS's default directory (which is C:\Inetpub\wwwroot). Here's where it gets weird. I had everything working fine and then moved my site from C:\Inetpub\wwwroot to D:\mysite. And when I say moved, I created a new folder on D:\ and copied all of the PHP files to the newly-created folder. Then I had all the problems with includes and path errors. Then, I gave up and deleted D:\mysite and for testing purposes, duplicated C:\Inetpub\wwwroot and renamed it to C:\mysite and EVERYTHING WORKS.

IIS is really busting my balls here. Why is this happening? Is it a permissions thing? As far as IIS is concerned, whether I define my site's root as the default (C:\Inetpub\wwwroot) or not shouldn't make a bit of difference as far as PHP's functionality goes... but it is! What gives?!

* EDIT *

WHAT THE!? This is just nuts.

If I create a folder on D: with the same name as the IIS default, IT WORKS. D:\Inetpub\wwwroot works. But D:\Inetpub\anything_else does NOT work. And if I set the root of the site to be ANYWHERE on C:, it works. I'm ready to jump out a window.

    9 days later

    Sounds to me like some kind of permission setting. As an administrator user on the server, you can check the permissions on a file or folder from windows explorer/properties page.

    I don't use IIS6, but previous IIS versions had a built-in user account IUSR_computername, used by IIS for anonymous (i.e., not authenticated) internet browsers. There is also an IWAM_name account used for network purposes, the usage is documented in the IIS documentation. I believe IIS6 added some more complexity to the IIS windows user accounts.

    Anyway, if your IIS is setup for anonymous users, and a web page tries to go to a file or folder without IUSR_ permissions, IIS will prompt for a login. If the user supplies proper login credentials, IIS will then "impersonate" the logged on user, and therefore the logon user will also require file permissions to any files used by the web.

    Further, asp.NET can set a user for IIS to impersonate user in code.

    I don't know if all this will help you though 🙂

      a month later

      Hey, Doug,

      Thanks for the follow-up, it is much appreciated.

      After about a week of no responses, I just conceded and left the damn files in D:\inetpub\wwwroot. To make matters worse, the problem does not happen on another server with a virtually identical software configuration (the one I had problems on is a Staging box and the other is a Production box). So, I just said, "F-it, if it works on the production machine, then I'll cope."

      Between the time I posted the original question and the time you responded, I had pretty much exhausted all of the possibilities with respect to permissions, users, user groups, etc. and nothing helped. I guess we'll deep-six this one and relegate IIS 6 to the dumpster heap as soon as it's feasible to do so.

      Take good care.

        An option that should be platform independant was written by Matt Zandstra over at www.getinstace.com. He wrote an article entitled "Death to The Dot" which removes the need for relative paths by defining the include path using the ini_set() function. Might want to take a look at it as it really does work!! 🙂

          2 years later

          Not to dredge-up an old subject... but is there any chance you can re-post that URL, bpat1434 (or anyone else who knows which site that might have been)?

          It looks like the board censored some word in the URL. What the ****? 🙂

          Honestly, I would like to know what site that was; I want to try that solution, even two years later.

          Thanks!

            Write a Reply...