...

View Full Version : Setting PHP Include Path in .htaccess



Joseph Witchard
04-04-2011, 12:25 PM
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.

djm0219
04-04-2011, 02:06 PM
The format below is correct and what I use on multiple sites.

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.

Joseph Witchard
04-05-2011, 04:59 AM
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:

<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:


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.

oesxyl
04-05-2011, 07:05 AM
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:

<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:


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/function.set-include-path.php#49454

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

http://www.php.net/results.php?q=include_path+bugs&l=en&p=wholesite

best regards

Joseph Witchard
04-05-2011, 07:30 AM
check last three posts from here:

http://www.php.net/manual/en/function.set-include-path.php#49454

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

http://www.php.net/results.php?q=include_path+bugs&l=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)?

oesxyl
04-05-2011, 07:40 AM
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/core.html#allowoverride

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

best regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum