# Error\_page not redirecting as expected

**URL:** <https://www.ruby-forum.com/t/error-page-not-redirecting-as-expected/224008>\
**Category:** NGINX\
**Created:** [October 26, 2012, 2:50pm UTC](https://www.ruby-forum.com/t/error-page-not-redirecting-as-expected/224008 "2012-10-26T14:50:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [October 26, 2012, 2:50pm UTC](https://www.ruby-forum.com/t/error-page-not-redirecting-as-expected/224008/1 "2012-10-26T14:50:39Z")

</div>

Hello,

I’m sure it’s something simple, but I don’t know where the problem is  
in the following configuration:

server {  
listen 80;  
server\_name [example.com](http://example.com);  
root /path/to/webroot;

error\_page 404 /status/404;

location / {  
try\_files $uri @dynamic;  
}

location @dynamic {  
include fastcgi\_params;  
fastcgi\_pass unix:/tmp/myapp.sock;  
fastcgi\_intercept\_errors on;  
}  
}

I have some static files (css, js, etc.) under webroot that are served  
by nginx. Everything else should be sent to @dynamic. If the initial  
@dynamic request is answered with 404, I want nginx to make a second  
request to @dynamic with the path set to /status/404.

What happens instead is that if the initial request receives a 404  
response from the FastCGI responder, nginx serves the default 404 Not  
Found page (not even the content returned by @dynamic) instead of  
rewriting the request to /status/404. Opening /status/404 directly  
works just fine.

Where did I make a mistake? There is nothing in the error log to give  
me any hints.

- Max
