php_value include_path in .htaccess

php_value include_path in .htaccess

Posted by: D9r
Posted on: 2008-04-21 08:38:00

I'm new at dreamhost and testing my site, and it almost works except for one thing: I'm having trouble resetting the include_path from inside the .htaccess file.

I'm using PHP include to include the header, footer, etc. The included files are in a folder named '/includes/', located in the main directory. The site has several levels of folders. For this to work, I need to define the include_path in the .htaccess file. It worked before at my previous host. Based on what worked previously, the .htaccess file should contain this line:

php_value include_path ".:/usr/local/php5/lib/php:/usr/local/lib/php:/home/username/example.net"

That does not seem to work. The webpages return this error:

Warning: require(includes/config.php) [function.require]: failed to open stream: No such file or directory in /home/.eric/username/example.net/directory/index.php on line 3

Fatal error: require() [function.require]: Failed opening required 'includes/config.php' (include_path='.:/usr/local/php5/lib/php:/usr/local/lib/php') in /home/.eric/username/example.net/directory/index.php on line 3

The error message doesn't acknowledge that I reset the path. Does 'Extra Web Security' need to be turned off?

Can someone please tell me what I'm doing wrong? I spent several hours searching the wiki but did not find anything regarding this.

Thanks.

Re: php_value include_path in .htaccess

Posted by: sXi
Posted on: 2008-04-21 11:37:00

Apache won't understand those directives as PHP is running as a CGI module.


Two quick solutions I think would be:

(1) Set the full path in the require() within the script, or

(2) Customise your PHP and edit the required paths in your php.ini


Re: php_value include_path in .htaccess

Posted by: rlparker
Posted on: 2008-04-21 13:19:00

Yep! There is also a "third option":

3) You can change the include_path setting in your script "on the fly" with the ini_set function.

--rlparker

Tags: htaccess filephp functiondirectory indexweb securityline 3fatal errorfolderserror messagelibwiki