ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

PATH_INFO suddenly empty; ORIG_PATH_INFO works instead

February 17, 2011 5:10pm

Subscribe [3]
  • #1 / Feb 17, 2011 5:10pm

    Andy C.

    5 posts

    Hi -

    My host must have changed something in its Apache or PHP settings, because suddenly in the last week or so, EE stopped parsing the URL segments when requests omitted index.php. (I use an .htaccess RewriteRule to add index.php to the request.) Adding AcceptPathInfo in my .htaccess didn’t seem to have any effect.

    After some debugging I found that while $_SERVER[‘PATH_INFO’] was empty, the ORIG_PATH_INFO variable was full. (Oddly, the reverse was true for requests that explicitly included index.php.) My solution was to hack index.php line 77 to check whether $_SERVER[‘ORIG_PATH_INFO’] is set, and use that for the $path_info variable if so. Everything is working again. But obviously that’s a hack. Any suggestions for a more elegant solution?

    Apache version 2.2.17
    PHP version 5.2.9
    EE version 1.7.0

    Andy

  • #2 / Feb 17, 2011 5:42pm

    Ingmar

    29245 posts

    Does it work as intended when you don’t attempt to remove index.php from your URLs?

  • #3 / Feb 17, 2011 6:40pm

    Andy C.

    5 posts

    Ingmar,

    If you mean, does it work when I get rid of the RewriteRule in .htaccess that adds index.php to the URI—I didn’t try that, since I was trying to fix the problem as quickly as possible in the middle of the day and didn’t want to break anything further. Perhaps early tomorrow morning I’ll give that a try.

    If you mean, does it work with requests that explicitly include the index.php, e.g., http://mysite.com/index.php/group/template—yes, that worked fine all along (and still works with my hack).

    Yours,

    Andy

    P.S. Current .htaccess code at my site root:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]
  • #4 / Feb 18, 2011 4:33am

    John Henry Donovan

    12339 posts

    Andy C.,

    Also open up your index.php in your root and you have the following lines. Try changing the value

    // URI Type
    // This variable allows you to hard-code the URI type.
    // For most servers, 0 works fine.
    // 0 = auto  
    // 1 = path_info  
    // 2 = query_string
    
    $qtype = 0;
  • #5 / Feb 18, 2011 8:13am

    Andy C.

    5 posts

    John, of course I did experiment with that first. All that $qtype does is choose between using the contents of $path_info and $query_string based on the contents of $path_info, or hard-code one or the other. The problem is that there is nothing in $path_info, so no matter what $qtype is, it will not be able to get segment information from $path_info. $path_info is set in line 77 of index.php based on the contents of $_SERVER[‘PATH_INFO’], which suddenly started being empty.

  • #6 / Feb 18, 2011 8:19am

    John Henry Donovan

    12339 posts

    Andy,

    Wiki entry here with some more info for you. What you have done is more of a workaround than a hack and perfectly ok.

  • #7 / Feb 18, 2011 8:34am

    Andy C.

    5 posts

    Ah, interesting! Yes, what that page recommends is exactly what I ended up with. Too bad I didn’t find it at the beginning of the hour I spent sorting this out! Thanks. Seems like it would be good, however, for EE to fall back on ORIG_PATH_INFO if PATH_INFO is empty as the default behavior, not as a workaround.

    Andy

  • #8 / Feb 18, 2011 8:47am

    Sue Crocker

    26054 posts

    You might want to consider making a Feature Request or finding an existing one if you need that kind of functionality.

    Glad John was able to help. Don’t hesitate to post again as needed.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases