# SetEnv PHPRC and Apache CGI redirection

- Thread: https://externals.io/message/32365
- Original archive: https://news-web.php.net/php.internals/32365
- Started by Tienshiao Ma on 2007-09-18T10:44:14+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #32365 — Tienshiao Ma — 2007-09-18T10:44:14+00:00

URL: https://externals.io/message/32365#32365

Hi all,

I did a quick search in the bug tracker and the mailing list archives 
and didn't see anything.

It looks like SetEnv PHPRC and Apache CGI redirection are not compatible.

When Apache is configured as indicated at 
http://php.net/security.cgi-bin and as recommended at 
http://www.php.net/manual/en/configure.php#configure.enable-force-cgi-redirect, 
it appears that SetEnv PHPRC cannot be used to specify a php.ini.

SetEnv PHPRC works (and can be seen when tested with a traditional CGI 
script, say written in Perl) but when the request goes to PHP via the 
internal Apache redirect, the PHPRC environmental variable gets 
rewritten as REDIRECT_PHPRC. This is why the CGI SAPI checks for the 
existence of the environmental variable REDIRECT_STATUS if 
"--enable-force-cgi-redirect" is specified.

Would it be reasonable to patch php_ini.c to check REDIRECT_PHPRC if 
FORCE_CGI_REDIRECT is defined? This way both the SetEnv method and the 
shell wrapper exporting PHPRC will work.

I just discovered the problem today, and have only skimmed through the 
php_ini.c code. Doesn't look too difficult to add to the search_path, 
but the ini_filename would probably require some sort of policy decision 
(which has precedence if both PHPRC and REDIRECT_PHPRC exist -- I assume 
PHPRC would).

Curious about how others feel about this issue.


Thanks,


Tienshiao
