Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top