skip to Main Content

how to make Prestashop 404 error pages redirected to homepage, and not to default template?
i did try everything – nothing works.
i did put it in .htacess -> not working,
i placed it in 404.tpl file too, manual redirect with javascript in the head, sadly it dont accept the changes and it is not working.
i am not able to find where it is stated and from where it redirects 404 errors to this shitty template page.
from SEO stand of view this hurts really bad.
Please help me.
Thanks.

(been trying to fix this from 5 days now and i got to a dead end.
u are my only hope. Please help!)

2

Answers


  1. I don’t exacly know Prestashop but as I know you have similar class to:

    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.
        }
    

    Probably it is stored there:

    PrestaShop/controllers/front/PageNotFoundController.php
    GitHub

    As you can see you may add header("Location index.php") up there. In place "Location <redirect_location>" you can write where you want to redirect. More informations you can find in PHP Manual: header

    Login or Signup to reply.
  2. Create override in override/controllers/front/PageNotFoundController.php with :

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

    Regards

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search