Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento has a redirect loop

Tags:

magento

My Magento web site home page has a redirect loop error. When I try to open it it goes to my old server url and gives the error:

The webpage resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer.

When I try to go into admin it takes to me old server admin url without any error.

I down loaded the fresh data base and connected my store to that it works fine but when i connect it my old data base it give same error.

Please advise me.

like image 856
user2344179 Avatar asked May 12 '13 12:05

user2344179


3 Answers

This isn't an ideal solution, but I was having issues with Magento 1.9.x.

The setup was: Nginx Proxy & SSL Terminator => Apache Webserver

No matter what I did enabling SSL caused a redirection loop. I narrowed the issue down to Magento rather than the Nginx configurations.

It was like Magento didn't know it was receiving a secure connection from Nginx even though the correct headers were set.

The dirty solution was to add some code to the very bottom of index.php within the magento root directory (ie. /var/www/magento) just before the Mage::run... line, like so:

if( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) ) {
    $_SERVER['HTTPS'] = 'on';
    $_SERVER['SERVER_PORT'] = 443;
}

Mage::run($mageRunCode, $mageRunType);
like image 94
Sabe Barker Avatar answered Oct 17 '22 18:10

Sabe Barker


Wrong permissions can also cause this to happen. So in addition to truncating the var/cache and var/session folders, go ahead and make sure that you have the proper permissions on the app, skin, and includes directories, sub-directories and files. I believe the suggested permission setting is 644. You can do this with a proper FTP client such as FireZilla.

like image 5
NotJay Avatar answered Oct 17 '22 18:10

NotJay


Go to table core_config_data

Update these value to be your localhost url(or whatever url you are providing while installation):

web/secure/base_url //(new url)

web/unsecure/base_url // (new url)

Empty the var folder.

like image 3
Ricky Sharma Avatar answered Oct 17 '22 19:10

Ricky Sharma