2.14.3.18. Setting up a 404 page in OpenCart

Attention!

Custom 404 page will not work correctly for URLs that mention pagespeedif included optimization settings. To fix the problem, disable optimization settings or not use links with similar keywords.

In OpenCart, the 404 error page is generated directly in the CMS itself, which is why the setup instructions your 404 page will not give the desired result.

You can create your 404 page in OpenCart by:

  1. Go to section "Design → Layouts»:
  2. Add a new layout by clicking "+»:
  3. Specify the data for creating the layout:
    1. "Layout name" — specify an arbitrary name for the layout.
    2. In a table with columns "Invoice" and "Way" click "+" and in the field "Invoice" select your active store, and in the field "Way" indicate error/not_found.
    3. In chapter "Select the location of the modules" clicking on "+" you can add a block with the desired element to the desired panel. The choice of such blocks must be done at your own discretion.
  4. Save your changes.
To change the text of the 404 page, you need to change the file catalog\language\ru-ru\error\not_found.phpwhere instead of ru-ru you need to specify the language you are using.

Only a few parameters will be specified in the file:

  • Title:
    // Heading
    $_['heading_title'] = 'The requested page was not found!';
  • Page text:
    // Text
    $_['text_error'] = 'Sorry, the page you requested was not found. Probably, you specified a non-existent address, the page was deleted, moved or is now temporarily unavailable!';

Both parameters can be changed to suit your needs. If you need to add any styles or pictures, you can use standard HTML tags. For example, to display an image, you can do this:

<?php
// Heading
$_['heading_title'] = 'The requested page was not found!';
 
// Text
$_['text_error'] = 'Sorry, the page you requested was not found. <img src = "https://example.com/404.png">';
Content