Gallery2 problem fix : Nice URLs mod-rewrite breaking with PHP-INFO
By fiLi • Oct 29th, 2007 • Category: Gallery2Yep, this title is a bit technical, but just might help those looking for a solution to this extremely annoying problem. Recently, two of my fellow niche bloggers have been having problems with their long running Gallery2 installations. Contacting support and searching the web usually does little to help find a fix to an undefined problem. One day your Gallery2 is working fine, the other it’s broken and you can’t login in any more.
I suggested the following fix, which I honestly don’t remember where I got it from almost a year back when I was still using shared-host accounts, and it worked like a charm. Turns out, not very surprising, that the broken Gallery2 is related to changes done by the shared-hosting companies to better protect their servers. This specific problem has to do with PHPINFO settings, which Gallery2’s mod-rewrite module is a bit sensitive about. Both bloggers found out that disabling mod-rewrite allows them to login, but that’s not a solution. This next one is:
Add the following lines in the .htaccess file (/making sure it’s there):
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php
Apply the following patch to the Gallery2 mod-rewrite module files :
file — modules/rewrite/classes/parsers/pathinfo/PathInfoUrlGenerator.class
if (($pathInfo = GalleryUtilities::getServerVar(’PATH_INFO’)) — before the changes
if (($pathInfo = GalleryUtilities::getServerVar(’ORIG_PATH_INFO’)) — after the changes
file — modules/core/classes/GalleryUrlGenerator.class
if (($tmp = GalleryUtilities::getServerVar(’ORIG_PATH_INFO’)) && $tmp != $path) { — after the changes
if (($tmp = GalleryUtilities::getServerVar(’PATH_INFO’)) && $tmp != $path) { — before the changes
Worked? great. Have a different solution? let me know…