2016-11-14 54 views
1

如何使Prestashop 404错误页面重定向到主页,而不是默认模板? 我尝试了一切 - 没有任何工作。 我确实把它放在.htacess - >不工作, 我也把它放在了404.tpl文件中,用javascript在头部手动重定向,可惜它不接受更改,它不工作。 我无法找到它在哪里陈述,并从404错误重定向到这个低劣的模板页面。来自SEO站点的 这种伤害真的很糟糕。 请帮帮我。 谢谢。如何使Prestashop 404错误页面重定向到主页,而不是默认模板?

(一直努力到现在的5天内解决这一点,我到了一个死胡同。 妳我唯一的希望。请帮助!)

+0

你在你的'.htaccess'像'的ErrorDocument 404写/ index.php'?你试过'<?php header(“Location:index.php”);?>'? –

+0

哪里?在.htacess中? – bloodstriker

+0

.htacess中的php代码?这可能吗? – bloodstriker

回答

0

我不知道exacly的Prestashop但我知道你有类似类:

class PageNotFoundControllerCore extends FrontController 
{ 
    public $php_self = 'pagenotfound'; 
    public $page_name = 'pagenotfound'; 
    public $ssl = true; 
    /** 
    * Assign template vars related to page content. 
    * 
    * @see FrontController::initContent() 
    */ 
    public function initContent() 
    { 
     header("Location: index.php") // delete everything here and add this line. 
    } 

也许它存储有:

的PrestaShop /控制器/前/ PageNotFoundController.php GitHub

正如你所看到的,你可以在那里添加header("Location index.php")。在地方"Location <redirect_location>"你可以写你想要重定向的地方。更多信息可以在PHP Manual: header

+0

你能告诉我怎么做吗? - 我的意思是在哪里粘贴...在哪个文件中。 – bloodstriker

+0

好吧让我试试吧 – bloodstriker

+0

这一切都在文件“/controllers/front/PageNotFoundController.php” sooo可能是它的错误文件? – bloodstriker

0

找到创建覆盖/控制器/前覆盖/ PageNotFoundController.php有:

class PageNotFoundController extends PageNotFoundControllerCore 
{ 
    public function initContent() 
    { 
     header('HTTP/1.1 301 Moved Permanently'); 
     Tools::redirect(__PS_BASE_URI__); 
     exit(); 
    } 
} 

问候

+0

它放在我把它放在文件中的哪个位置吗? – bloodstriker

+0

你在我的答案中找到了地方。 –

+0

谢谢,让我试试看,并再次生病说出发生了什么 – bloodstriker

相关问题