Redirect 404 or only 404 headers

I am currently coding a site and I want to find out a better alternative.

Should I add a header("HTTP/1.0 404 Not Found") without redirection, or do I need to redirect and add a 404 header?

+4
source share
3 answers

Forwarding means "you really requested."

If it is not found, it is not found. Do not redirect.

Print a 404 status code, and then an HTML document that explains that everything requested was not found. Then you can offer to continue the journey, for example, by providing links to the main sections of the site or performing a search based on keywords extracted from the URL.

(The practical consequences of redirecting are that the URL disappears from the address bar, making it difficult to see the thought β€œOh, I saddened this letter, I just changed it” or copy / paste it into the error report, etc.).

+10
source
 header("Status: 404 Not Found"); //FastCGI include("404.php"); exit; 

The URI remains as requested by the user.

+4
source

You should redirect to the error page, but make sure that you set the status to 404. The error page can give users tools to continue, such as a sitemap, search, an explanation of what they tried to load, and for example, β€œSorry, but the page you requested was not found. "

Better yet, make your page 404 script and use it to register errors so that you can learn about common ones and fix them. This may be for you too.

+2
source

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


All Articles