1

After patching a Magento 1.6.0.0 site with SUPEE-9767 I am getting an infinite redirect loop.

There were no errors applying the patch.

I am running it on Apache2.2 with PHP 5.4 on CentOS 6.

The site has 2 stores on it, not sure if that could be causing it?

The logs show that it is doing a bunch of 302 redirects:

{IP_ADDRESS} - - [02/Jun/2017:11:09:52 -0400] "GET / HTTP/1.1" 302 217 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
{IP_ADDRESS} - - [02/Jun/2017:11:09:52 -0400] "GET / HTTP/1.1" 302 - "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
{IP_ADDRESS} - - [02/Jun/2017:11:09:52 -0400] "GET / HTTP/1.1" 302 217 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
{IP_ADDRESS} - - [02/Jun/2017:11:09:52 -0400] "GET / HTTP/1.1" 302 - "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
{IP_ADDRESS} - - [02/Jun/2017:11:09:53 -0400] "GET / HTTP/1.1" 302 217 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"

Any idea how to fix this?

1

Identified the root cause of this issue. It was apparently because of these lines

Quick Fix

Find the below lines inside the method protected function _checkBaseUrl($request) in the file app/code/core/Mage/Core/Controller/Varien/Front.php

 if (isset($uri['scheme']) && $uri['scheme'] != $request->getScheme()
        || isset($uri['host']) && $uri['host'] != $request->getHttpHost()
        || isset($uri['path']) && strpos($requestUri, $uri['path']) === false
 ) {  

Change these lines to

 if (isset($uri['host']) && $uri['host'] != $request->getHttpHost()
            || isset($uri['path']) && strpos($requestUri, $uri['path']) === false
 ) { 

After that save the file (commit to your REPO), clear the cache (remove everything inside var/cache folder) and reload your store front. You should find the site loads without anymore 302 redirect issues after applying the SUPEE 9767 Patch.

Root Cause

The difference in SCHEME value between the actual Request and the URI after redirection. Eg: The actual request returns the scheme HTTP but the scehme in the URI can be HTTPS

Possible Underlying Reasons

  1. You may most likely have a redirect rule in .htaccess file to redirect all the http requests to https.

  2. Both the base secure and unsecure URLs begin with https

  • 1
    It was Mage::app()->getStore()->isCurrentlySecure() changed to Mage::getConfig()->shouldUrlBeSecure($request->getPathInfo()) in line 303 (308 after patch) of that file. It now does not think that / needs to be secured when I visit the site using https://. It redirects to http:// but then apache forces it to https:// causing the loop. – Eric Jun 30 '17 at 19:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.