Monday, March 1, 2010

Joomla 1.5: Can't login to back-end with Forced SSL for Back-end

When setting the Back-end to force use SSL, it will do that, but won't let you log in.
You will go in an endless login cycle.
To solve this you will need to dig in the code and change a few lines.
(Credit to original poster: John-Paul Takats)

Change  the file  ../libraries/joomla/environment/uri.php



               if(trim($live_site) != '') {
                $uri =& JURI::getInstance($live_site);
                $base['prefix'] = $uri->toString( array('scheme', 'host', 'port'));
                $base['path'] = rtrim($uri->toString( array('path')), '/\\');
                if(JPATH_BASE == JPATH_ADMINISTRATOR) {
                $base['path'] .= '/administrator';
                }

to

                if(trim($live_site) != '') {
                $uri =& JURI::getInstance($live_site);
                $base['prefix'] = $uri->toString( array('scheme', 'host', 'port'));
                $base['path'] = rtrim($uri->toString( array('path')), '/\\');
                /*
                * John-Paul Takats Fix for SSL login Loop problem
                *  -----------------------------------------------
                */              
                if(JPATH_BASE == JPATH_ADMINISTRATOR) {

                    $force_ssl = $config->getValue('config.force_ssl');
                       if($force_ssl > 0){
                              $base['prefix'] = ereg_replace("http://","https//", $base['prefix']);
                       }
                    $base['path'] .= '/administrator';
                }

1 comment:

Please be courteous, even if you do not share the same view.