A
A
Alexey Klyonin2018-11-10 21:27:03
1C-Bitrix
Alexey Klyonin, 2018-11-10 21:27:03

In Bitrix, instead of 404, it gives the code 200 and does not go to the 404 page, what's the matter?

Good evening
I ran into a problem, instead of a 404 page and an error in Bitrix, the code 200 is given if you enter the address for example site.ru/abrakadabra
- There is a 404.php page in the root of the site. Saved in UTF-8 without BOM. When you try to open site.ru/404.php it does not open, just the main one remains.
- In the main module, it is not worth giving 200 instead of 404.
- Website on BitrixVM latest version, Bitrix 18.0.4 itself (demo for 30 days), on hosting (running, same problem).
What could be the reason?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kontrael, 2018-11-14
@Kontrael

1. Check .htaccess at the root. Line ErrorDocument 404 /404.php
2 should be present. Go directly to the file with 404 //site.ru/404.php If the page is not white, then the problem is in the logic of "which page to show", if white, then in the page itself. Perhaps somewhere they forgot to remove die(); when debugging
If after opening the content of the page, there will still be a 200 status, you need to add this to the top of 404.php

<?php
include_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/urlrewrite.php');
CHTTP::SetStatus("404 Not Found");
@define("ERROR_404","Y");
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
use Bitrix\Main\Localization\Loc;
$APPLICATION->SetTitle("Страница не найдена");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question