@jorshjorsh95

Почему ErrorDocument 404 отдает 302?

Добрый день, в htaccess:
ErrorDocument 404 http://site.ru/404.php

Все страницы строго html файлами, но при обращении к несуществующему, например site.ru/men21djakd.html

Редиректит на 404, и вроде все хорошо, но сервер отдает 302, а нужно сразу 404.

Подскажите пожалуйста, как реализовать (единой точки входа нет, чтобы решить это дело php)?
  • Вопрос задан
  • 547 просмотров
Пригласить эксперта
Ответы на вопрос 1
@dodo512
https://httpd.apache.org/docs/2.4/mod/core.html#er...
Note that when you specify an ErrorDocument that points to a remote URL (ie. anything with a method such as http in front of it), Apache HTTP Server will send a redirect to the client to tell it where to find the document, even if the document ends up being on the same server. This has several implications, the most important being that the client will not receive the original error status code, but instead will receive a redirect status code.

Всё что начинается на http:// https:// трактуется как внешний ресурс, даже если там ссылка на тот же самый домен.
Редирект происходит из-за указания схемы и хоста.

ErrorDocument 404 /404.php
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы