D
D
dmitry2511902019-11-14 14:18:59
Nginx
dmitry251190, 2019-11-14 14:18:59

How to give server response code 404 instead of 200 on any page of the site?

How to give server response code 404 instead of 200 on any page of the site? And how to make the search engines throw out the site from their database so that it does not appear in the search results? Will they throw out all the pages from the database if the pages give 404?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
Nujabes37, 2019-11-14
@Nujabes37


How to give a server response code 404 instead of 200 on any page of the site
location / {
     return 404;
}

And how to make the search engines throw out the site from their database so that it does not appear in the search results?
location /robots.txt {
      add_header Content-Type text/plain;
      return 200 "User-agent: *\nDisallow: /\n";
}

M
Mikhail Lyalin, 2019-11-14
@mr_jok

depends on the final goal - even 404 can return from the cache, etc.

D
Dmitry, 2019-11-14
@MaKvc

1. Use the meta robots = noindex + tag to create, and exclude everything in robots.txt
2. The most reliable option, for any url request, is to issue randomly generated text, in this case, the site will not only disappear from the search results, but will also receive a BAN!
The answer to the 404 question.
Yes! The site will disappear from the search results, but the site will quickly recover in the ranking after the 404 error is removed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question