MrG*_*ass 3 php http-status-codes magento http-status-code-301
我的任务是强制所有404页面返回http状态301.我一直在网上搜索/阅读,但我找不到任何有关如何完成此操作的信息.
有没有办法更改layout.xml或模板文件中的http状态?如果没有,我应该看什么控制器?
小智 5
我没有太多关注它,但404消息似乎是在这个文件中发送 - 在3个函数中:
服务器路径:/ app/code/core/Mage/Cms/controllers
我将标头从404更改为301重定向.可能不是最琐碎的解决方案,但似乎有效.
**/**
* Default index action (with 404 Not Found headers)
* Used if default page don't configure or available
*
*/
public function defaultIndexAction()
{
$this->getResponse()->setHeader('HTTP/1.1, 301 Moved Permanently');
$this->getResponse()->setHeader('Location','http://www.streetcred.dk');
}
/**
* Render CMS 404 Not found page
*
* @param string $coreRoute
*/
public function noRouteAction($coreRoute = null)
{
$this->getResponse()->setHeader('HTTP/1.1, 301 Moved Permanently');
$this->getResponse()->setHeader('Location','http://www.streetcred.dk');
}
/**
* Default no route page action
* Used if no route page don't configure or available
*
*/
public function defaultNoRouteAction()
{
$this->getResponse()->setHeader('HTTP/1.1, 301 Moved Permanently');
$this->getResponse()->setHeader('Location','http://www.streetcred.dk');
}**
Run Code Online (Sandbox Code Playgroud)