Y
Y
Yaroslava2019-04-18 21:11:36
1C-Bitrix
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");
  @define("ERROR_404","Y");

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"){
      GLOBAL $APPLICATION;
      $APPLICATION->RestartBuffer();
      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)
A
Anton, 2019-04-22
@anton99zel

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

A
Alexander, 2019-04-18
@idruweb

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

Y
Yaroslav Alexandrov, 2019-04-19
@alexyarik

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

D
Dmitry Platonov, 2019-04-20
@molotok_studio

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