A
A
avshivtseva2017-10-24 16:34:13
1C-Bitrix
avshivtseva, 2017-10-24 16:34:13

How to set up a 404 page in the directory component?

404 page does not work,
the CNC of the component is set as follows

"SEF_URL_TEMPLATES" => array(
      "sections" => "",
      "section" => "#SECTION_CODE#/",
      "element" => "#SECTION_CODE#/#ELEMENT_CODE#/",
      "compare" => "compare.php?action=#ACTION_CODE#",
      "smart_filter" => "#SECTION_CODE#/filter/#SMART_FILTER_PATH#/apply/",
    ),

Similarly, in the infoblock.
There are parameters
"SET_STATUS_404" => "Y",
    "SET_TITLE" => "Y",
    "SHOW_404" => "Y",

in init.php
AddEventHandler('main',   'OnEpilog',   '_Check404Error', 1);
function _Check404Error(){
  if(defined('ERROR_404') && ERROR_404=='Y' || CHTTP::GetLastStatus() == "404 Not Found"){
    GLOBAL $APPLICATION;
    $APPLICATION->RestartBuffer();
    $APPLICATION->SetPageProperty("keywords", "Страница не найдена");
    $APPLICATION->SetPageProperty("title", "Страница не найдена");
    $APPLICATION->SetPageProperty("description", "Страница не найдена");
    $APPLICATION->SetPageProperty("ADDITIONAL_TITLE", "Страница не найдена");
    require $_SERVER['DOCUMENT_ROOT'].SITE_TEMPLATE_PATH.'/header.php';
    require $_SERVER['DOCUMENT_ROOT'].'/404.php';
    require $_SERVER['DOCUMENT_ROOT'].SITE_TEMPLATE_PATH.'/footer.php';
  }
}

Nov through such a url goes to the element, and does not show the 404 page http://farmhouse43.ru/proekty/any_word/vyaz/

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Mukovoz, 2017-10-25
@castomi

Need to deal with CNC settings, do you have pure Nginx without apache?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question