My favorites | Sign in
Logo
             
New issue | Search
for
| Advanced search | Search tips
Issue 195: Problem with friendly URL without the index.php prefix in CGI mode
1 person starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  ----
Type-Defect
Priority-Medium
Milestone-3.1.7


Sign in to add a comment
 
Reported by rrsant...@yahoo.com, Aug 11, 2009
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
Sign in to add a comment

Hosted by Google Code