« Previous Next »

Thread: Subdirectory as another site ?

Last post 07-13-2009 5:00 PM by dilbert627. 3 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (4 items)

Sort Posts:

  • 07-10-2009, 5:10 PM

    Subdirectory as another site ?

    We have an internal website that runs a php application. I am adding a new feature in a subdirectory that I want to expose to the internet.  My thought was that I would make a website that runs under a different port, like 84, then port forward from the router.  I am running IIS 6 on SBS 2003.   So I created a new website and pointed it to the subdirectory of the other site, but when I pull it up it acts like it's loading the index file of the root site, not the subdirectory. In the code, I'm loading a config file based on the document_root, but that fails because it's looking in the subdirectory for the config file.  Here's the structure so hopefully this will make more sense:

     Root web site

    --index.php

    \config\config.php

    \commercial\index.php

     

    Commercial website (same path on disk as commercial subdirectory of other site)

    index.php

     

    The code is:

        require($_SERVER["DOCUMENT_ROOT"] . "/config/config.php");
     

    When I load the page I get this:

    Fatal error: require() [function.require]: Failed opening required 'C:\Inetpub\tracker\commercial/config/config.php' (include_path='.;c:\php\includes') in c:\Inetpub\tracker\index.php on line 3

     

    Now I could change the code so it loads the right path instead of the document root, but it's not loading commercial/index.php, it's loading the root index.php. So what's up with that?  Is there another, better way to do this???  Thanks for any help.

  • 07-12-2009, 6:47 AM In reply to

    Re: Subdirectory as another site ?

    If you have config in the subdirectory that has access to the root folder of the main site, you'll have to A) Either have a specific config for the sub-directory, or have a separate folder.  I wouldn't use a different port, I'd use a host-header on port 80.  Make sure also the new site
    Home Directory property is configured to c:\inetpub\wwwroot\commercial

    Steve Schofield
    Windows Server MVP - IIS
    http://weblogs.asp.net/steveschofield


    http://www.IISLogs.com
    Log archival solution
    Install, Configure, Forget
  • 07-13-2009, 11:53 AM In reply to

    Re: Subdirectory as another site ?

     Ok, so I made a copy of the config directory in the subdirectory, and as I suspected, it's loading the index page of the root directory, only without the graphics and styles because the path is different, and none of the links work. Does the doc_root somehow override the home directory setting??

  • 07-13-2009, 5:00 PM In reply to

    Re: Subdirectory as another site ?

     Actually doc_root WAS the problem. As per this thread: http://forums.iis.net/t/1154314.aspx

     You can't have doc_root set in php.ini if you're going to have multiple sites. I still had to have a separate config directory, but not having doc_root set allowed each site to have its own document_root which was correct. 

Page 1 of 1 (4 items)