simple redirect()函数在symfony 1.4中不起作用

simple redirect()函数在symfony 1.4中不起作用,redirect,controller,symfony-1.4,Redirect,Controller,Symfony 1.4,我假设我在这里做了一些明显的错误,但我不知道是什么。我的代码非常简单: 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.googl

我假设我在这里做了一些明显的错误,但我不知道是什么。我的代码非常简单:

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 );
  }
}
我知道模板正在加载这个动作,因为我可以在这个动作中编写草率的代码,它将在我的浏览器中显示。除此之外,以下是基本路线:

forward_page:
  url:   /forward
  param: { module: static, action: forward }
你的symfony大师有没有一个痛苦而明显的答案来解释为什么这不起作用?我非常感谢您朝正确的方向轻推。

404是一个错误代码: 请尝试302代码,这表示重定向。顺便说一下,这是此选项的默认值:

我也有类似的问题。我认为问题在于$this->redirect。据我所知,$this->redirect期望第一个参数是symfony路由。它不接受外部URL。不确定我是否正确。

我尝试输入302,并尝试将其默认设置为302。我知道默认行为以及错误代码的含义。谢谢你的努力!好的,请原谅我误解了你的问题。顺便说一句,我已经测试了你的代码,它是有效的!