Monday, July 1, 2013

Re: 301 infinite redirect

The easiest way to debug redirect problems is to put:

public function redirect($url) {
    debug($url);
    debug(Debugger::trace());
    die;
}

OR

public function redirect($url) {
    $this->log($this->here);
    $this->log($url);
    $this->log(Debugger::trace());
    parent::redirect($url);
}

Or similar, In your app controller, and determine why/how/what causes the problem url to redirect to itself.

AD

On Monday, 1 July 2013 14:46:05 UTC+2, floydbrush wrote:
Hi,

I need to made a 301 redirect from one url to another. So i tried to use:

$this->redirect($newUrl, 301);

The redirect works first time, but is infinite and throws ERR_TOO_MANY_REDIRECTS, so Search Engines bots can't index the new url.

I checked the headers and I don't understand why the hell not stops once the redirect is made after first 301. Example: http://urivalet.com/?http://www.pasteleria.com/noticias/view/el-chocolate-ya-se-consumia-en-el-1150-a-c/179#Report

I started a "clean" cakephp app  for try if there's a problem with my current app, and the behaviour is the same.

If I use redirect 302 instead of 301, the redirect works fine (or 303, 307, 404...). Only causes a loop with 301.

I have no idea what is happening. Any tips?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: