Примечательно, что если я просто что-то ввожу после раздела, например https://site.ru/razdel1/asdasdasd/ , то все работает и на странице показывается страница 404.
P.S. Используется комплексный компонент bitrix:news . В настройках компонента установлена галочка для показа 404 страницы.
Alexey Voitov wrote: Good day! The next task is. It is necessary to show a 404 page for a non-existent element of the infoblock section. Example:
https://site.ru/razdel1/element45/ - where element45 is an element of section 2, ( https://site.ru/razdel2/element45/) . Those. if i'm in url section https://site.ru/razdel1 / I substitute the symbolic code of an element from another section (element45), I need to display a 404 page. At the moment https://site.ru/razdel1/element45/FaceTime PC gives 404 in the title, but displays "Element not found" on the page itself. It is noteworthy that if I just enter something after the section, for example https://site.ru/razdel1/ asdasdasd /, then everything works and the page displays page 404. PS The complex component bitrix: news is used. The checkbox for displaying a 404 page is set in the component settings.
You've spent a lot of time making sure your website is user-friendly, has a descriptive navigation, is organized in a way that makes sense, but what if someone makes a typo when typing in a URL? What if another website links to a page you don't have any longer? What will the user see on your 404 error page?
Решил эту проблему проверкой на наличие $arResult['VARIABLES']['SECTION_CODE'] в detail.php компонента bitrix.news . Почему-то именно если подставить в урл раздела не его элемент, то этот параметр будет отсутствовать в arResult. Кто-нибудь может объяснить почему так происходит?