Submit Your Article Forum Rules

Results 1 to 6 of 6

Thread: HELP! including php file in subdirectory using SSI

  1. #1
    WebProWorld MVP Orion's Avatar
    Join Date
    Sep 2003
    Posts
    716

    HELP! including php file in subdirectory using SSI

    that's what we're doing worked fine before upgrade to php5

    now it doesn't work

    I can include any php file in the same directory in the shtml and it works but as soon as you include a .php file from a subdirectory it stops functioning...

    anyone have an idea how to solve this? we're thinking some setting in httpd.conf file.. but what and where? possibly in php.ini dunno???

    HELP!
    Ron Boyd
    website consulting - design • optimization • marketing • [url=http://owhosting.com]Hosting[url] :: Follow Me: @boydrw

  2. #2
    WebProWorld MVP wige's Avatar
    Join Date
    Jun 2006
    Posts
    3,138
    I can think of a few possible causes. Try creating a simple test.php file in the subdirectory in question, like this:
    Code:
    Text Test
    <?php="PHP Test" ?>
    Start by accessing the test file directly. If you don't get the PHP Test text when accessing the file directly, the problem is with executing php in the subdirectory; if you don't get any text at all, the problem is with the server dealing with files in the subdirectory (permissions maybe).
    If everything works when accessing the file directly, check the SSI. If you get the PHP Test portion, the problem is with the script you were trying to use, some ini configuration setting has changed and broken the script, possibly a change in how some environmental variable is handled. If you only get the Text Test, the problem is probably in the PHP.ini file, and the resolution will depend on how your server interacts with the PHP interpreter. If you don't get anything with the SSI, it is a problem with the way your server handles subdirectories... check if there is or should be a leading slash, and check the config.
    Unfortunately cant really tell you anything specific, but this should help you narrow down the source of the problem.
    The best way to learn anything, is to question everything.
    WigeDev - Freelance web and software development

  3. #3
    WebProWorld MVP Orion's Avatar
    Join Date
    Sep 2003
    Posts
    716
    I have more info...

    php works fine btw... over 120 sites all working about 50% have at least some php on them.

    ok get this..

    SSI works fine...

    If I include virtual the .php file in the .shtml and the php file is located in the same directory as the .shtml .. IT WORKS

    If I move the .php into a sub directory (where they all are) IT DOESN"T WORK

    If I change my include to file and the .php is in the sub directory IT WORKS (that shouldn't I know).

    So where? what? are the settings in httpd.conf or php.ini (or are they elsewhere php 5 bugfix?) to be able to allow the includes virtual to work in subdirectories when dealing with .php files..

    OR

    what is it we have as a setting that could be screwing it up?
    Ron Boyd
    website consulting - design • optimization • marketing • [url=http://owhosting.com]Hosting[url] :: Follow Me: @boydrw

  4. #4
    WebProWorld MVP wige's Avatar
    Join Date
    Jun 2006
    Posts
    3,138
    What server are you using? If it is Apache, have you gone through the server's error log to see if it is giving an error message? (usually /var/log/httpd/errorlog)

    Also, is there plain text output in the file you are including are is all of the output contained in php tags? There are a few possible issues... the server may not be finding the file, the server may not be able to access the file (php added a "safe mode" that attempts to prevent unauthorized access to certain things, including if one directory has different permissions or a different owner than another) or the server may simply not be sending the file to the PHP interpreter.

    The best way to narrow down these possibilities is to check the server log for any messages, and see if non-php output is being rendered. Also check what method you are using to execute PHP scripts. Probably not part of the issue, but may be relevant.
    The best way to learn anything, is to question everything.
    WigeDev - Freelance web and software development

  5. #5
    WebProWorld MVP Orion's Avatar
    Join Date
    Sep 2003
    Posts
    716
    [Mon Sep 18 02:19:39 2006] [error] [client 69.157.226.6] Directory index forbidden by rule: /var/www/vhosts/herbacentral.com/httpdocs/

    that's the only error we get...

    -safemode is off
    -yes it's apache / php5 all through plesk 8.0.1
    -we uploaded the entire site using one ftp user name.. and before that we chown the entire httpdocs dir and all files / folders in it to reset just in case

    all the included files are .php with php code in them
    we can include them no problem using
    Code:
    <!#include file="/includes/file.php">
    or
    Code:
    <!#include virtual="/file.php">
    however if you use
    Code:
    <!#include virtual="/includes/file.php">
    it doesn't work.


    So it's something to do with the virtual directive being unable to include a file in a subdirectory if that file has a .php extension (works fine for all other extensions).

    anyone????
    Ron Boyd
    website consulting - design • optimization • marketing • [url=http://owhosting.com]Hosting[url] :: Follow Me: @boydrw

  6. #6
    WebProWorld MVP wige's Avatar
    Join Date
    Jun 2006
    Posts
    3,138
    From what I understand, PHP5 has added additional security checks to prevent the PHP script from accessing files that would not otherwise be accessible from the web server. From the error message that you indicated, the PHP processor may be trying to verify that the server has access to the PHP script before executing it.

    Unfortunately I am not sure how to confirm that this is the problem or how to do a workaround.
    The best way to learn anything, is to question everything.
    WigeDev - Freelance web and software development

Similar Threads

  1. Which is Better? SEO domain name or subdirectory?
    By wisesolutions in forum Search Engine Optimization Forum
    Replies: 8
    Last Post: 02-26-2009, 06:13 PM
  2. Subdomain and Subdirectory issue
    By freetutes in forum Search Engine Optimization Forum
    Replies: 5
    Last Post: 10-04-2008, 06:22 AM
  3. Set up navigation to a subdirectory?
    By wael in forum Graphics & Design Discussion Forum
    Replies: 3
    Last Post: 10-17-2007, 12:11 PM
  4. New site as subdirectory or new domain name?
    By johnie99 in forum Search Engine Optimization Forum
    Replies: 5
    Last Post: 06-12-2005, 10:33 AM
  5. Trying to redirect entire subdirectory
    By equickxpress in forum Web Programming Discussion Forum
    Replies: 4
    Last Post: 01-11-2005, 10:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •