NVG
NVG

Reputation: 3343

nGinx custom error pages

I am new to nGinx and I need some help redirecting all errors to a default page.

EG: I want all 500 Internal Server errors and 404 Not Found errors to be redirected to http://www.mydomain.com/error.php

I currrently added this into my nginx.conf file:

http {
    server {
        error_page 404 http://www.mywebsite.com/error.php;
        error_page 500 http://www.mywebsite.com/error.php;

        }
................
................
}

But nothing happens after I restart nGinx.

When I visit a page that doesn't exist, I still get the default error page from nGinx.

Upvotes: 0

Views: 908

Answers (2)

mcuadros
mcuadros

Reputation: 4144

Are you using FastCGI or Proxy?

To get working with FastCGI or Proxy Maybe, you must switch proxy_intercept_errors or fastcgi_intercept_errors to on.

Upvotes: 1

Pixou
Pixou

Reputation: 1769

you may have another "server" section in another conf file which overrides this setting. Place your error_page directives in the conf file that handles your site.

Upvotes: 0

Related Questions