Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Oct 2008
    Posts
    255
    Thanks
    113
    Thanked 0 Times in 0 Posts

    Setting PHP Include Path in .htaccess

    Code:
    php_value include_path /home/myusername/include_directory
    php_value include_path .:/home/myusername/include_directory
    php_value include_path "/home/myusername/include_directory"
    php_value include_path ".:/home/myusername/include_directory"
    I have searched and searched Google for a way to set the path to the directory where I keep my include files in .htaccess. My host assures me that they allow me to set it up this way, and I tried each of the above (some tutorials did it different than others), but every time I got a 500 internal server error, no matter which syntax I tried. Does anyone have any ideas on what else to do? I would greatly appreciate some help.

  • #2
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,307
    Thanks
    4
    Thanked 205 Times in 202 Posts
    The format below is correct and what I use on multiple sites.
    Code:
    php_value include_path ".:/home/myusername/include_directory"
    What doesn't look correct is your path. There is most likely directories above /home that you need to be including in that path. If the problem persists look at the server log to see exactly what it is reporting the problem is.
    Dave .... HostMonster for all of your hosting needs

  • Users who have thanked djm0219 for this post:

    Joseph Witchard (04-05-2011)

  • #3
    Regular Coder
    Join Date
    Oct 2008
    Posts
    255
    Thanks
    113
    Thanked 0 Times in 0 Posts
    I checked my error log and it said php_value was not a valid command.


    **EDIT: I made a little headway, but not much. I got it to recognize that it was a valid command by changing it to the following:
    Code:
    <IfModule mod_php5.c>
       php_value include_path ".:/home/myusername/include_directory"
    </IfModule>
    But now it's claiming that no such file or directory exists. I have that set in my .htaccess, and I have the following in my test file:

    PHP Code:
    include('filename.php'); 
    Now I was doing my testing in a subdirectory instead of my document root, because I didn't want to risk ruining my live site. From everything I've read, I don't think that should be a problem, but I thought I would mention it just in case.
    Last edited by Joseph Witchard; 04-05-2011 at 05:58 AM.

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Joseph Witchard View Post
    I checked my error log and it said php_value was not a valid command.


    **EDIT: I made a little headway, but not much. I got it to recognize that it was a valid command by changing it to the following:
    Code:
    <IfModule mod_php5.c>
       php_value include_path ".:/home/myusername/include_directory"
    </IfModule>
    But now it's claiming that no such file or directory exists. I have that set in my .htaccess, and I have the following in my test file:

    PHP Code:
    include('filename.php'); 
    Now I was doing my testing in a subdirectory instead of my document root, because I didn't want to risk ruining my live site. From everything I've read, I don't think that should be a problem, but I thought I would mention it just in case.
    check last three posts from here:

    http://www.php.net/manual/en/functio...path.php#49454

    also check the bugs related htaccess and include_path to your php versions:

    http://www.php.net/results.php?q=inc...en&p=wholesite

    best regards
    Last edited by oesxyl; 04-05-2011 at 07:07 AM.

  • Users who have thanked oesxyl for this post:

    Joseph Witchard (04-05-2011)

  • #5
    Regular Coder
    Join Date
    Oct 2008
    Posts
    255
    Thanks
    113
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by oesxyl View Post
    check last three posts from here:

    http://www.php.net/manual/en/functio...path.php#49454

    also check the bugs related htaccess and include_path to your php versions:

    http://www.php.net/results.php?q=inc...en&p=wholesite

    best regards
    Thank you. Do I need to set AllowOverride inside the conditional statement or outside? Also, does it matter which one I use (Options or All)?

  • #6
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Joseph Witchard View Post
    Thank you. Do I need to set AllowOverride inside the conditional statement or outside? Also, does it matter which one I use (Options or All)?
    if i'm not wrong is not allowed in htaccess, only in the apache configuration file inside a Directory block.

    http://httpd.apache.org/docs/2.2/mod...#allowoverride

    if i need to choose between few directive to achive same thing, i usualy prefere the one with more restrictions.

    best regards


  •  

    Posting Permissions

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