php/apache includes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dave

    php/apache includes

    Hello,
    Not sure if this is an apache configuration or a php configuration
    problem, i'm hoping someone can help. I'm running a webserver on FreeBSD
    consisting of apache2 and php4 among other items. I've got a site that has
    an alias directive defined in httpd.conf like:

    alias /include "/path/to/directory/include"

    In that area i have a file header.php which contains standard information i
    want displayed across my web pages. In my index file i have:

    <? include "/include/header.php"; ?>

    The header.php file is not being included, not sure why. Any pointers
    appreciated.
    Thanks.
    Dave.


  • Tim Van Wassenhove

    #2
    Re: php/apache includes

    In article <b2gKc.221347$D G4.124426@fe2.c olumbus.rr.com> , dave wrote:[color=blue]
    > consisting of apache2 and php4 among other items. I've got a site that has
    > an alias directive defined in httpd.conf like:
    >
    > alias /include "/path/to/directory/include"[/color]

    This means that Apache knows that /include is an alias for /path/foo
    [color=blue]
    > In that area i have a file header.php which contains standard information i
    > want displayed across my web pages. In my index file i have:
    >
    ><? include "/include/header.php"; ?>[/color]

    PHP will ask your filesystem (not Apache) for /include/bar.php

    Perhaps you may want to change the include_path setting.

    --
    Tim Van Wassenhove <http://home.mysth.be/~timvw>

    Comment

    • Chung Leong

      #3
      Re: php/apache includes


      "dave" <dmehler26@woh. rr.com> wrote in message
      news:b2gKc.2213 47$DG4.124426@f e2.columbus.rr. com...[color=blue]
      > Hello,
      > Not sure if this is an apache configuration or a php configuration
      > problem, i'm hoping someone can help. I'm running a webserver on FreeBSD
      > consisting of apache2 and php4 among other items. I've got a site that has
      > an alias directive defined in httpd.conf like:
      >
      > alias /include "/path/to/directory/include"
      >
      > In that area i have a file header.php which contains standard information[/color]
      i[color=blue]
      > want displayed across my web pages. In my index file i have:
      >
      > <? include "/include/header.php"; ?>
      >
      > The header.php file is not being included, not sure why. Any pointers
      > appreciated.
      > Thanks.
      > Dave.
      >[/color]

      Apache aliases don't affect require()/include() in PHP script. PHP loads the
      file directly from the filesystem, hence we need a filesystem path. It can
      be either absolute or relative. For the latter, the path is relative to the
      directory which contain the running script. So if index.php is in
      /path/to/directory, you would do include("includ e/header.php").



      Comment

      Working...