Why is it bad to have a 200 OK header status on a 404 error page?

I have a problem: I have a problem: / err404 page 200OK there is a problem with the header, although it should be 404. What is wrong if you have 200 OK? is there something similar 200 OK should be in the state of the 404 error page header?

Appreciate the tips! thanks a lot!


I assume it is related to .htaccess. here is my .htaccess file;

ErrorDocument 404 /err404.html RewriteEngine On RewriteRule ^login.html$ index.php?s=login&a=loginDo [QSA,L] RewriteRule ^logout.html$ index.php?s=login&a=logoutDo [QSA,L] RewriteRule ^([^/]*).html$ index.php?s=$1 [QSA,L] RewriteRule ^members/([^/]*)$ index.php?s=profile&username=$1 [QSA,L] RewriteRule ^([^/]*)/$ index.php?s=listing&search[cityString]=$1 [QSA,L] RewriteRule ^([^/]*)/([^/]*)/$ index.php?s=listing&search[neighborhoodString]=$2 [QSA,L] RewriteRule ^([^/]*)/([^/]*)/([^/]*).html$ index.php?s=details&seo_friendly=$3 [QSA,L] 

I also have some problems related to this htaccess file :(

Question 1; when the url is like http: //localhost/fdfcdcvdvdvbdf.html (no url exists), it redirects to the main page, but it should redirect to err404.html. Any ideas on the issue? err404 redirection works well in the case of a url like http: //localhost/fdfcdcvdvdvbdf.ht or <a2>

Question 2; How can I fix this problem 200 OK: /

+4
source share
7 answers

By returning the status of 200 OK for missing pages, you confuse browsers (error messages may not be displayed if you do not have a custom HTML error) and search engines (they will begin to index everything that someone tells them about, for example .com / this -web-this-terribly-consuming-our-competitor) ...


Regarding your edit about mod_rewrite:
http://example.com/lsdjkldsjlk.html matches your third RewriteRule , so it will be redirected to index.php.

The index.PHP script is where you should not detect content related to the s parameter and return 404 status through the header() call.

+6
source

The value 404 is not only a decoration of the Christmas tree - it conveys real information about the url in question, namely that it does not exist. Sending a 200-page page that describes the fact that the page does not exist is a completely different thing, especially for a program, unlike a person.

+20
source

First, you probably don't want search engines to index your 404 pages.

+3
source

Well, the semantics of HTTP are pretty clear: if the requested page is not found on the server, 404 should be sent.

Also, if you don't mind your site crawling / indexing with garbage (when pages are not found) ...

+2
source

This is not a 404 error page if it returns 200 status. Everything that should fail if the page is inaccessible (caches, proxies, scripts) is not interrupted, and chaos occurs. In addition, Google will hate you (because spam sites return 200 pages for any request.) Just return damn 404 error.

+2
source

By the way, do you know where 404 came from in the "404 error page"? This is exactly the HTTP error code.

The software should be able to distinguish between correct and incorrect pages. If you send a page with the image “404” as the image, no software will ever know that something is wrong.

+1
source

This is an accessibility issue. 200 OK means that the submitted resource is the requested resource. 404 means that the requested resource cannot be found, and the resource sent out is an error page. Browsers use the status code that you send to see if everything is OK. You will not notice any differences on the displayed page as a person, but the crawlers should know such things (or they will index your errors, etc.).

+1
source

Source: https://habr.com/ru/post/1302420/


All Articles