为什么 Zend Framework 的 $this->_redirect($url, array('code'=>301)) 会导致 302 代码?
当我打电话时:
$this->_redirect($url, array('code'=>301));
我被重定向,但 http 代码是 302 而不是 301。知道为什么吗?
When I call:
$this->_redirect($url, array('code'=>301));
I get redirected, but the http code is 302 instead of 301. Any idea why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试使用以下命令将重定向代码设置为 301:
try setting redirect code to 301 using:
看来使用 _redirect 方法总是会将代码设置为 302。如果您想手动更改响应代码,请使用 重定向器 代替。
It appears that using the _redirect method will always set the code to a 302. If you'd like to manually change the response code, use a redirector instead.
在 Zend/Controller/Action/Helper/Redirector.php 中: _redirect 调用 $this->getCode(); getCode() 是 $this->_code 的简单 getter; _code 初始化为 302。
In Zend/Controller/Action/Helper/Redirector.php: _redirect called $this->getCode(); getCode() is simple getter for $this->_code; _code initialized with 302.