200 response on Nginx 404 error page
Asked Answered
T

2

5

My server uses a custom 404 page. Is't possible to get 404 server response on a direct request of 404 page? Now: URL: http://mydomain.xxx/404.php HTTP/1.1 200 OK Server: nginx

Tern answered 14/8, 2013 at 16:29 Comment(1)
Could you clarify your question?Interpretive
C
15

you can simply do

error_page 404 =200 /404.php;
Camporee answered 14/8, 2013 at 18:6 Comment(1)
Do I have to specify /404.php? I'd like to keep the current page but just do a 200 error.Varices
T
0

Serve /404.html content preserving original URL (404 status code).

server {
    error_page 404 /404.html;

    location = /404.html {
        internal;
    }

    location / {
        try_files $uri $uri/index.html $uri.html;
    }
}
Theater answered 8/8, 2023 at 17:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.