phpapache.htaccessfastcgimod-php

Conditional .htaccess based on apache server API


I'm having trouble with .htaccess, specifically changing the include_path value. On my dev server PHP is ran as a module, so I can use:

php_value  include_path "/whatever/path/i/want"

Now when I migrated to the real server, PHP is ran as CGI/FastCGI, so my last trick doesn't work, so i've learned the hard way and got it all working using apache handlers so it loads a custom php.ini with the include path changed:

AddHandler php5-fastcgi .php
Action php5-fastcgi /cgi-bin/php.fcgi

Now here comes the question. I need a codition block for each case, so it uses a handler if is executing as CGI/FastCGI or php_value if is as a module.

Found this for fastcgi but didn't make it work.

<IfModule fastcgi_module>
   AddHandler php5-fastcgi .php
   Action php5-fastcgi /cgi-bin/php.fcgi
</IfModule>

If there is another way to change include_path in both cases not depending on how is PHP executed, and not hardcoding it into the code, would be much aprecciated.


Solution

  • .user_ini file should help you in case of CGI/FastCGI. Normally it's ignored for mod_php.