V
V
valentyn812019-06-10 18:15:15
htaccess
valentyn81, 2019-06-10 18:15:15

Customizing 404 errors for html site?

Good afternoon, a question for programmers on setting up 404 errors for the html site. I created a 404.html file, added it to .htaccess (ErrorDocument 404 url.../404.html),
closed it for viewing in the robots.txt file (Disallow: /404.html), uploaded everything to the hosting, everything works. But when checking a broken link on the site, bertal.ru gives HTTP/1.1 200 OK, although in theory it should give HTTP/1.1 404 NOT FOUND. I read on the forums that it is necessary to write a function in the code, but this is for php, but I don’t use php, only html. What am I doing wrong, thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-06-10
@dodo512

https://httpd.apache.org/docs/2.4/mod/core.html#er...
Anything that starts with http:// https:// is treated as an external resource, even if it links to the same domain. When requesting a broken link, Apache will return a 302 redirect to the client to that external resource. The client will request http://site.ru/404.htmland receive the code 200 OKand contents of this file.
If you do not specify the scheme and host, then Apache will immediately return the code 404 Not Found.
ErrorDocument 404 /404.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question