# Error directive help with 404

**URL:** <https://www.ruby-forum.com/t/error-directive-help-with-404/189342>\
**Category:** NGINX\
**Created:** [May 29, 2010, 12:24am UTC](https://www.ruby-forum.com/t/error-directive-help-with-404/189342 "2010-05-29T00:24:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![robinsonc494](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/d9b06d/32.png) [@robinsonc494](https://www.ruby-forum.com/u/robinsonc494)\
**Post date:** [May 29, 2010, 12:24am UTC](https://www.ruby-forum.com/t/error-directive-help-with-404/189342/1 "2010-05-29T00:24:22Z")

</div>

Hi all,  
I’ve just moved from an apache2 server and i’m trying to set up nginx.

Its installed, compiled from source and running fine.  
In the process of fine tuning my setup i noticed my 404’s aren’t doing  
what i want.

I have my wordpress blog setup with php-fpm for php

when a 404 happens on a file with .html or /no-existent-url  
the 404 does what i expect and wordpress handles it with my custom page.

if i enter [domain.com/somepage.php](http://domain.com/somepage.php) i get the nasty default page that  
browsers server.  
in I.E especially

my server config looks like this

```
server {
    listen 80;
    server_name www.domain.com;

       try_files $uri $uri/ /index.php?q=$uri&$args;
    #error_page 404 /index.php?error=404;
    location / {
        root /usr/share/nginx/html;
        index index.html index.htm index.php;
    if (!-e $request_filename) {
    rewrite ^ /index.php last;
    }
    error_page 404 /swf/404.php;
  location = /swf/404.php {
    root /usr/share/nginx/html;
  }

    }

```

I’ve searched about and found examples of the error\_page directive being  
used not specifically for a 404 but i assumed its the same.  
It doesn’t seem to work though.  
Can anyone help me please?

Posted at Nginx Forum:

> **[error directive help with 404](https://forum.nginx.org/read.php?2,91680,91680#msg-91680)**
>
> Hi all, I've just moved from an apache2 server and i'm trying to set up nginx. Its installed, compiled from source and running fine. In the process of fine tuning my setup i noticed my 404's aren't doing what i want. I have my wordpress blog setup...

---

<div class="post-metadata">

**Author:** ![robinsonc494](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/d9b06d/32.png) [@robinsonc494](https://www.ruby-forum.com/u/robinsonc494)\
**Post date:** [May 30, 2010, 11:57pm UTC](https://www.ruby-forum.com/t/error-directive-help-with-404/189342/2 "2010-05-30T23:57:21Z")

</div>

Hello!

On Fri, May 28, 2010 at 06:23:13PM -0400, robinsonc494 wrote:

> if i enter [domain.com/somepage.php](http://domain.com/somepage.php) i get the nasty default page that browsers server.  
> in I.E especially

So you have 404 returned from php, and it’s returned to browser as  
is. Use fastcgi\_intercept\_errors to intercept backend errors, see  
here:

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

Maxim D.

---

<div class="post-metadata">

**Author:** ![robinsonc494](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/d9b06d/32.png) [@robinsonc494](https://www.ruby-forum.com/u/robinsonc494)\
**Post date:** [June 1, 2010, 12:04am UTC](https://www.ruby-forum.com/t/error-directive-help-with-404/189342/3 "2010-06-01T00:04:53Z")

</div>

Hi,  
thanks for responding.  
i tried that but then i get “no input file specified”  
I’m using php-fpm not fastcgi if that makes a difference…

thanks

Posted at Nginx Forum:

> **[Re: error directive help with 404](https://forum.nginx.org/read.php?2,91680,92852#msg-92852)**
>
> Hi all, I've just moved from an apache2 server and i'm trying to set up nginx. Its installed, compiled from source and running fine. In the process of fine tuning my setup i noticed my 404's aren't doing what i want. I have my wordpress blog setup...
