Nginx Custom 404 Image for Bad Image Requests

In NGINX conf for my site I include a rewrites file (site_rewrites) that has this:

location ~* ^.+\.(ico|gif|jpg|jpeg|png|bmp|css)$ {
          expires 30d;
#        rewrites here

I include this file for the primary domain and the subdomain (so don’t have to repeat code). But, I’d like a custom image 404 error to be added. So something like:

 location ~* ^.+\.(ico|gif|jpg|jpeg|png|bmp|css)$ {
                error_page 404 /img/404.jpg;

The problem is that NGINX ignores this and sticks to the rewrites rules in the included file. So I’m guessing you can’t declare the same location twice?


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.