D
D
das342015-11-10 13:12:17
PHP
das34, 2015-11-10 13:12:17

Code 200 instead of 404, how to fix?

The site gives the code 200 with an empty page instead of 404 for any requests (except those that are prohibited in the rewrite rules), how to fix it how to win it?
GET /asdasd%D1%84%D1%8B%D0%B2%D1%84%D1%8B%D0%B2%D1%84%D1%8B%D0%B2 HTTP/1.1" 200 288
GET /a123123123 HTTP/ 1.1" 200 288
RewriteEngine on
.htaccess
RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteRule .* - [F]
# core core file - pass on for processing
RewriteRule ^index.php$ - [L]
RewriteRule ^libs\/.*$ - [F]
RewriteRule ^cronjobs\/.*$ - [F]
RewriteRule ^js\/.*$ - [L]
RewriteRule ^pic\/.*$ - [L]
RewriteRule ^admin\/.*$ - [L ]
# disable server scripts
RewriteRule ^pics\/.*\.php$ - [F]
RewriteRule ^pics\/.*\.phtml$ - [F]
RewriteRule ^pics\/.*\.php3$ - [F]
RewriteRule ^pics\/ .*\.cgi$ - [F]
RewriteRule ^pics\/.*\.pl$ - [F]
RewriteRule ^pics\/.*$ - [L]
RewriteRule favicon.ico - [L]
RewriteRule ^.*. inc.php$ - [F]
RewriteRule ^.*.user.ini$ - [F]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /index.php/ [L]

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor Shansky, 2015-11-10
@Amstor

ErrorDocument 404 /404.html
only pre-create the error file
But in your case, it seems to me that it is worth digging into the files and looking for conditions with errors, most likely they are closed with the phrase "header location .. tra ta ta" or something like that

if(!isset($_GET['path']) or empty($_GET['path']))
{
  message('Это и есть наш 200', '/');
}

and accordingly the error is perceived as code 200 (aka header redirect) and not 404

H
Host-Eiweb, 2016-11-10
@Host-Eiweb

You can easily fix this with PHP.

<?php 
header("Location: https://site.com/404.php", true); 
header ("HTTP/1.1 404 Not Found"); 
?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question