|
|
What steps will reproduce the problem?
1. Setup friendly URL under a PHP_CGI environment, with urlPrefix as "/";
2. Open a page using /index.php/virtual-page.html (this will not use
URLrewrite)
3. Open a page using /virtual-page.html (this will not work under CGI
environment)
4. Put an echo Prado::varDump($_SERVER) just before the app->run() in the
index.php to compare the environment variables passed (note PHP_SELF,
SCRIPT_NAME, PATH_INFO, ORIG_PATH_INFO, ORIG_SCRIPT_NAME). Comparing those
variables in CGI mode both for opening a page with and without rewrite
(item 2 and 3) shows that crucial environment variables comes with
different contents.
Prado 3.1.6-r2699, Apache 2.2 and PHP in CGI mode.
There are two tested solutions for this:
1. Modifying prado:
THttpRequest.php
In the method init(), the part that checks the path info becomes:
(...)
if(isset($_SERVER['ORIG_PATH_INFO']))
$this->_pathInfo=$_SERVER['ORIG_PATH_INFO'];
else if(isset($_SERVER['PATH_INFO']))
$this->_pathInfo=$_SERVER['PATH_INFO'];
else
if(strpos($_SERVER['PHP_SELF'],$_SERVER['SCRIPT_NAME'])===0 &&
$_SERVER['PHP_SELF']!==$_SERVER['SCRIPT_NAME'])
$this->_pathInfo=substr($_SERVER['PHP_SELF'],strlen($_SERVER['SCRIPT_NAME']));
else
$this->_pathInfo='';
And the getApplicationUrl() method becomes:
public function getApplicationUrl()
{
if(isset($_SERVER['ORIG_SCRIPT_NAME']))
return $_SERVER['ORIG_SCRIPT_NAME'];
else
return $_SERVER['SCRIPT_NAME'];
}
2. php.ini solution:
; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for
CGI. PHP's
; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to
not grok
; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs.
Setting
; this to 1 will cause PHP CGI to fix it's paths to conform to the spec. A
setting
; of zero causes PHP to behave as before. Default is 1. You should fix
your scripts
; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
cgi.fix_pathinfo=0
Some references:
http://php.net/manual/en/ini.core.php#ini.cgi.fix-pathinfo
http://bugs.php.net/bug.php?id=31843
http://hoohoo.ncsa.illinois.edu/cgi/env.html
|