Fixing PATH_INFO on bluehost and other shared hosts


The first time I setup an Expression Engine site on bluehost, and removed the index.php file via the .htaccess file, I ran into a problem where every template was redirecting back to the main index template. At the time, I traced this down to fact that the “segments” were not getting populated properly.
A brief search led to the EE wiki, which advocated swapping out PATH_INFO for ORIG_PATH_INFO. Although not being a fan of hacking core stuff, I was kind of cornered into this, so I went for it. This has been my running solution for the past two years.
Recently, I ran into an issue where the $_SERVER['PHP_SELF'] was not returning anything after the file name. In other words, for http://mysite/foo.php/bar, PHP_SELF should be equal to foo.php/bar.
I spoke with my host about it (a similar host to bluehost), and they said to put the following in the php.ini file: cgi.fix_pathinfo=Off
After, I did this, PHP_SELF worked fine. Unfortunately, I ran into a similar situation like I described at the outset. Then it hit me…I changed ORIG_PATH_INFO back to PATH_INFO and…it worked!
So now I listed this as another potential solution in the EE wiki.

, , , ,

  1. #1 by PureDezigner at March 6th, 2010

    I’m wondering if you could help me out I have been trying to remove the index.php for 3 days now with no luck. I am on bluehost for hosting. Could you possibly provide me a working example of .htaccess code and any additional settings that need adjustment on bluehost severs?

    I look forward to your reply. – Thanks!

  2. #2 by Coastal Web Development at August 29th, 2010

    I experienced this problem using the CodeIgniter framework on BlueHost under a subdomain. My fix ended up being adding the following line to my php.ini:

    cgi.fix_pathinfo = 0

    • #3 by Avi at August 29th, 2010

      0 == Off, so I’m glad I could help out!

(will not be published)
  1. No trackbacks yet.