Answer the question
In order to leave comments, you need to log in
Bitrix why does not work 404.php?
When accessing a non-existent address, for example, /blablabla, the main page is always returned with the code 200. And you need to show the 404.php file, which lies at the root. What could be the problem? The setting "Send status 200 to 404 error in header" is disabled.
Answer the question
In order to leave comments, you need to log in
Faced this error several times. The reason is that they pressed something in the wrong place, entered something wrong in the CNC settings when setting up any component.
Next, Bitrix added a rule to the urlrewrite.php file, which lies at the root of the site, that breaks the logic of opening the desired page.
See what page opens instead of /404.php
Next, see which rule leads to this page (['PATH'] ==> '...'). Try wrapping this rule in a comment and see if the error is gone. If it's gone, delete the rule.
In the file \bitrix\php_interface\init.php add:
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';
}
}
The problem is in .htaccess.
Add to the question which one you have.
The standard one looks like this:
Options -Indexes
ErrorDocument 404 /404.php
<IfModule mod_php5.c>
php_flag session.use_trans_sid off
#php_value display_errors 1
#php_value mbstring.internal_encoding UTF-8
</IfModule>
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/bitrix/urlrewrite.php$
RewriteRule ^(.*)$ /bitrix/urlrewrite.php [L]
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>
<IfModule mod_dir.c>
DirectoryIndex index.php index.html
</IfModule>
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/jpeg "access plus 3 day"
ExpiresByType image/gif "access plus 3 day"
ExpiresByType image/png "access plus 3 day"
ExpiresByType text/css "access plus 3 day"
ExpiresByType application/javascript "access plus 3 day"
</IfModule>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question