Yaroslava2019-04-18 21:11:36
Yaroslava, 2019-04-18 21:11:36

404 does not work in Bitrix, standard solutions do not help?

404 error does not work on Bitrix.
site.ru/fgsdfgsdg - returns 200 and a white page.
At the same time, in other situations on the site, the error works well:
site.ru/catalog/sfgsdgfsg - gives both the 404 code and a beautiful error page (which excludes the fact that 404 does not work and is not configured in principle)
What has already been checked:
1. In htaccess there is a line ErrorDocument 404 /404.php
2. 404.php is and it has

CHTTP::SetStatus("404 Not Found");

3. Added to the file \bitrix\php_interface\init.php - did not help:
AddEventHandler('main', 'OnEpilog', '_Check404Error', 1);  
function _Check404Error(){
   if(defined('ERROR_404') && ERROR_404=='Y' || CHTTP::GetLastStatus() == "404 Not Found"){
      require $_SERVER['DOCUMENT_ROOT'].SITE_TEMPLATE_PATH.'/header.php';
      require $_SERVER['DOCUMENT_ROOT'].'/404.php';
      require $_SERVER['DOCUMENT_ROOT'].SITE_TEMPLATE_PATH.'/footer.php';

This option was suggested here in a similar old question.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
Anton, 2019-04-22

Configuring the main module, uncheck "Send status 200 to 404 error in header"

Alexander, 2019-04-18

Check that the _Check404Error function is executed.
Replace SITE_TEMPLATE_PATH with your folder.

Yaroslav Alexandrov, 2019-04-19

Download the hosting check script and check for Bitrix compliance, it may be in the server https://www.1c-bitrix.ru/download/scripts/bitrix_s...

Dmitry Platonov, 2019-04-20

Check the urlrewrite.php file at the root to see if there is a rule that matches any request
like this

array (
    'CONDITION' => '#^/#',
    'RULE' => '',
    'ID' => 'bitrix:news',
    'PATH' => '/new/index.php',
    'SORT' => 100,

If there is, then the error must be processed already in the file that is connected

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question