Steve Adams
Steve Adams

Reputation: 2837

simple redirect() function not working in symfony 1.4

I am assuming I'm doing something blatantly wrong here, but I can't figure out what. My code is very simple:

public function executeForward(sfWebRequest $request)
{
  //redirect traffic that has landed here to either advertiser's or our own lander
  if ( rand(1, 100) > 50 )
  {
    $this->redirect( 'http://www.google.com', 404 );
  }
  else
  {
    $this->redirect( 'http://www.bing.com', 404 );
  }
}

I know the template is loading this action as I can write sloppy code in this action and it will 500 in my browser. On top of that, here is the basic route:

forward_page:
  url:   /forward
  param: { module: static, action: forward }

Do any of your symfony masters have a painfully obvious answer as to why this doesn't work? I'd greatly appreciate a nudge in the right direction.

Upvotes: 0

Views: 2723

Answers (2)

Bennet Joseph
Bennet Joseph

Reputation: 336

I have a similar issue. I think the problem is with $this->redirect. As far as I could understand, $this->redirect expects the first parameter to be a symfony route. It does not accept external URLs. Not sure I am correct.

Upvotes: 0

dxb
dxb

Reputation: 931

404 is an error code : http://en.wikipedia.org/wiki/HTTP_404 Try a 302 code, it's indicate a redirection. BY the way, it's the default value of this option:
http://trac.symfony-project.org/browser/branches/1.4/lib/action/sfAction.class.php

Upvotes: 1

Related Questions