php.ini and auto_prepend_file question

Discussion in 'PHP' started by stephan2307, Oct 1, 2008.

  1. #1
    Hi,

    I just started to play with the php.ini and the auto_prepend_file functionality. If I have a subdomain which is located in the following sample path on the server

    /public_html/subdomain

    and in that subdomain I got a php.ini file which automatically ads a header, Is it possible to do it for all files even in subfolders of that domain.

    The file that I want to prepend is currently in the public_html folder.

    my current php.ini file looks like this


    auto_prepend_file = "../top.inc"
    Code (markup):
    thanks for any advice.
     
    stephan2307, Oct 1, 2008 IP
  2. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #2
    Use the full path to the file instead of a relative path.

    If I understand your situation right PHP should be attempting to prepend the file everywhere already, it's just that when it tries while in other subdirectories the relative path is translating to the parent directory instead of the grandparent directory.
     
    joebert, Oct 1, 2008 IP
  3. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    #3
    Yeah tried that as well but as soon as I go into the subfolder of the subdomain it wont work. It always just works on the root folder of that subdomain.
     
    stephan2307, Oct 1, 2008 IP
  4. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #4
    I guess it can't be the path, auto_prepend_file functions like require() meaning you'ld get a fatal error if it wasn't finding the file.

    I'm not familiar with per-directory php.ini files, however since auto_prepend_file is a PHPINI_PER_DIR confiruration you should be able to override it in htaccess and Apache would propagate it into the subdirectories.

    php_value auto_prepend_file "/public_html/top.inc"
    Code (markup):
    That is unless you're running PHP as CGI instead of an Apache Module.
     
    joebert, Oct 1, 2008 IP