I was curious if PHP as an Apache module makes its ini values available in htaccess files? For example, I know that in a mod_rewrite rule, you can access environment variables like %{HTTP_HOST}, so would it, for example, be possible to append to PHP's include_path in an htaccess, rather than in each individual script? Something like the following (which doesnt work, but illustrates what I'd like to do).

php_value include_path "%{INCLUDE_PATH}:/home/sitename/library"

That (or something like it) would allow me to permenantly add to the existing include path, so even if the original path in php.ini is changed, I wouldn't have to change each htaccess. Is something like this possible?

    Thanks for the link. I didn't see anything definitive though, so I'm guessing that's a no?

      Check this page in the manual:

      Indeed, it is clearly linked from the manual entry that I linked to.

        I think I poorly phrased my question. I know I can override the include_path from an htaccess file:

        php_value include_path .:/usr/local/php/pear:/home/somesite/library

        What I was wondering is if, instead of overriding it completely, I could append to what was already specified in the php.ini file through some kind of environment variable:

        # assuming ".:/usr/local/php/pear" was set in php.ini
        php_value include_path %{INCLUDE_PATH}:/home/somesite/library

        Nothing I have seen in the docs definitively indicates either way, but I'm guessing then that this is probably not possible.

          I am not aware of a way to do that. You could, however, add an auto_prepend_file to your .htaccess, and in that file use ini_set() to set the include path:

          <?php
          $addPath = '/home/somesite/library';
          $path = sprintf("%s%s%s", ini_get('include_path'), PATH_SEPARATOR, $addPath;
          

            Some web hostings allows setting custome php.ini in any directory to override the default one.

              Write a Reply...