Anth0ny
Anth0ny

Reputation: 59

200 response on Nginx 404 error page

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

Upvotes: 5

Views: 10239

Answers (2)

Predaytor
Predaytor

Reputation: 144

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;
    }
}

Upvotes: 0

Mohammad AbuShady
Mohammad AbuShady

Reputation: 42899

you can simply do

error_page 404 =200 /404.php;

Upvotes: 15

Related Questions