Redirect 将所有404页重定向到prestashop中的主页

Redirect 将所有404页重定向到prestashop中的主页,redirect,http-status-code-404,prestashop,Redirect,Http Status Code 404,Prestashop,如何将所有404页面重定向到prestashop中的主页 提前感谢。PS 1.5 controllers/front/PageNotFoundController.php 添加简单重定向到主页 public function __construct() { Tools::redirect(_PS_BASE_URL_); exit; } 对于PS 1.5 controllers/front/PageNotFoundController.php 添加简单重定向到主页 public

如何将所有404页面重定向到prestashop中的主页

提前感谢。

PS 1.5

controllers/front/PageNotFoundController.php

添加简单重定向到主页

public function __construct()
{
    Tools::redirect(_PS_BASE_URL_);
    exit;
}
对于PS 1.5

controllers/front/PageNotFoundController.php

添加简单重定向到主页

public function __construct()
{
    Tools::redirect(_PS_BASE_URL_);
    exit;
}

将以下行添加到.htaccess文件中:

ErrorDocument 404 /index.php

在.htaccess文件中添加以下行:

ErrorDocument 404 /index.php

在/超控/控制器/前部/ 创建一个名为:PageNotFoundController.php的文件

我们进入:

class PageNotFoundController extends PageNotFoundControllerCore
    {

    public function initContent()
    {
        Tools::redirect(_PS_BASE_URI_);
        exit;
     }
}

删除/override/controllers/front中的cache/class_index.php/ 创建一个名为:PageNotFoundController.php的文件

我们进入:

class PageNotFoundController extends PageNotFoundControllerCore
    {

    public function initContent()
    {
        Tools::redirect(_PS_BASE_URI_);
        exit;
     }
}

从用户体验的角度删除cache/class_index.php

,我强烈建议您不要这样做。用户更可能认为重定向是偶然的,而不是故意的,因此再次查询页面。从用户体验的角度来看,我强烈建议您不要这样做。用户更可能认为重定向是偶然的,而不是故意的,因此再次查询页面。