Menu

#162 PATH_INFO not available

open
nobody
None
v0.10.0
1
2014-12-22
2013-11-21
nwtn
No

Some hosting environments (e.g. Dreamhost) don't expose PATH_INFO or ORIG_PATH_INFO, which causes problems. The required data should be available in other vars, though, such as SCRIPT_NAME, REQUEST_URI, etc.

Below is the output from var_dump($_SERVER) from a Dreamhost server with this issue (w/ identifying data removed). Let me know if you need more info.

array(44) {
  ["PATH"]=>
  string(29) "/bin:/usr/bin:/sbin:/usr/sbin"
  ["RAILS_ENV"]=>
  string(10) "production"
  ["SCRIPT_NAME"]=>
  string(9) "/test.php"
  ["REQUEST_URI"]=>
  string(5) "/test"
  ["QUERY_STRING"]=>
  string(6) "query="
  ["REQUEST_METHOD"]=>
  string(3) "GET"
  ["SERVER_PROTOCOL"]=>
  string(8) "HTTP/1.1"
  ["GATEWAY_INTERFACE"]=>
  string(7) "CGI/1.1"
  ["REDIRECT_URL"]=>
  string(5) "/test"
  ["REDIRECT_QUERY_STRING"]=>
  string(6) "query="
  ["REMOTE_PORT"]=>
  string(5) "33523"
  ["SCRIPT_FILENAME"]=>
  string(43) "/home/xxx/xxx/test.php"
  ["SERVER_ADMIN"]=>
  string(33) "xxx"
  ["DOCUMENT_ROOT"]=>
  string(34) "/home/xxx/xxx"
  ["REMOTE_ADDR"]=>
  string(13) "xxx"
  ["SERVER_PORT"]=>
  string(2) "80"
  ["SERVER_ADDR"]=>
  string(14) "xxx"
  ["SERVER_NAME"]=>
  string(23) "xxx"
  ["SERVER_SOFTWARE"]=>
  string(6) "Apache"
  ["SERVER_SIGNATURE"]=>
  string(0) ""
  ["HTTP_COOKIE"]=>
  string(111) "xxx"
  ["HTTP_ACCEPT_LANGUAGE"]=>
  string(14) "en-US,en;q=0.8"
  ["HTTP_ACCEPT_ENCODING"]=>
  string(17) "gzip,deflate,sdch"
  ["HTTP_USER_AGENT"]=>
  string(119) "xxx"
  ["HTTP_ACCEPT"]=>
  string(74) "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
  ["HTTP_CONNECTION"]=>
  string(5) "close"
  ["HTTP_HOST"]=>
  string(23) "xxx"
  ["DH_USER"]=>
  string(4) "xxx"
  ["xxx"]=>
  string(0) ""
  ["dsid"]=>
  string(8) "xxx"
  ["SCRIPT_URI"]=>
  string(35) "http://xxx/test"
  ["SCRIPT_URL"]=>
  string(5) "/test"
  ["UNIQUE_ID"]=>
  string(24) "xxx"
  ["REDIRECT_STATUS"]=>
  string(3) "200"
  ["REDIRECT_DH_USER"]=>
  string(4) "xxx"
  ["xxx"]=>
  string(0) ""
  ["REDIRECT_dsid"]=>
  string(8) "xxx"
  ["REDIRECT_SCRIPT_URI"]=>
  string(35) "xxx"
  ["REDIRECT_SCRIPT_URL"]=>
  string(5) "/test"
  ["REDIRECT_UNIQUE_ID"]=>
  string(24) "xxx"
  ["FCGI_ROLE"]=>
  string(9) "RESPONDER"
  ["PHP_SELF"]=>
  string(9) "/test.php"
  ["REQUEST_TIME_FLOAT"]=>
  float(1385077586.0609)
  ["REQUEST_TIME"]=>
  int(1385077586)
}

Discussion

  • Christian Weiske

    Thanks for the fix. It would be easier for me to integrate it if you posted the output of var_export($_SERVER) - please do so if you can.

     
  • Christian Weiske

    Could you do the same for the URL "/test.php/dummy"?

    Also, do you get a PATH_INFO variable if you put "AcceptPathInfo On" in .htaccess?

     
  • nwtn

    nwtn - 2013-12-04

    Interesting. When going to /test.php/dummy I do get a PATH_INFO variable, even without AcceptPathInfo On in the .htaccess (see below).

    Going to /test/, however, still does not give a PATH_INFO variable, even with AcceptPathInfo On.

    array (
      'PATH' => '/bin:/usr/bin:/sbin:/usr/sbin',
      'RAILS_ENV' => 'production',
      'PATH_TRANSLATED' => '/xxx/www/dummy',
      'PATH_INFO' => '/dummy',
      'SCRIPT_NAME' => '/test.php',
      'REQUEST_URI' => '/test.php/dummy',
      'QUERY_STRING' => '',
      'REQUEST_METHOD' => 'GET',
      'SERVER_PROTOCOL' => 'HTTP/1.1',
      'GATEWAY_INTERFACE' => 'CGI/1.1',
      'REMOTE_PORT' => '51848',
      'SCRIPT_FILENAME' => '/xxx/www/test.php',
      'SERVER_ADMIN' => 'xxx@xxx.xxx',
      'DOCUMENT_ROOT' => '/xxx/www',
      'REMOTE_ADDR' => 'xxx.xxx.xxx.xxx',
      'SERVER_PORT' => '80',
      'SERVER_ADDR' => 'xxx.xxx.xxx.xxx',
      'SERVER_NAME' => 'xxx',
      'SERVER_SOFTWARE' => 'Apache',
      'SERVER_SIGNATURE' => '',
      'HTTP_COOKIE' => 'xxx',
      'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.8',
      'HTTP_ACCEPT_ENCODING' => 'gzip,deflate,sdch',
      'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36',
      'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
      'HTTP_CONNECTION' => 'close',
      'HTTP_HOST' => 'xxx',
      'DH_USER' => 'xxx',
      'ds_id_xxx' => '',
      'dsid' => 'xxx',
      'SCRIPT_URI' => 'http://xxx/test.php/dummy',
      'SCRIPT_URL' => '/test.php/dummy',
      'UNIQUE_ID' => 'xxx',
      'FCGI_ROLE' => 'RESPONDER',
      'PHP_SELF' => '/test.php/dummy',
      'REQUEST_TIME_FLOAT' => 1386171491.8225,
      'REQUEST_TIME' => 1386171491,
    )
    
     
  • Christian Weiske

    But this is fine; it's like it should behave.

    Do you have problems with that? Which problems?

     
  • nwtn

    nwtn - 2013-12-04

    Ya, now I'm second-guessing the whole thing. I'll have to take another look to figure out exactly what was happening. I will update this ticket with more info shortly.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.