VisezTrance

  • April 29, 2009 1:11 AM

    Returning an nginx status code

    By Daniel
    I really grew tired of having an old rss feed hit 404s on my website. From what I've read the best way to retire it is to respond with a 410 message, and the program that makes all those requests will stop, in theory any way.
    I've added the following lines in my nginx conf:

    location ~ /  {
      if ($uri ~ "/my/old/url") {
        return 410;
      }
      ..
    }

    To make it prettier, I also added:
    error_page 410 /410.html
    The syntax is a bit odd though, because the 410 ("It's gone") is not an http error code.
    You can add additional codes such as 502 (bad gateway) or 503 (service not available) and style them to your hearts content.

    Tags:

    • nginx
  • Monthly Archives

    • October 2013 (2)
    • May 2012 (1)
    • October 2011 (1)
    • September 2011 (2)
    • March 2011 (3)
    • February 2011 (1)
    • January 2011 (1)
    • September 2010 (1)
    • August 2010 (1)
    • June 2010 (1)
    • April 2010 (1)
    • December 2009 (1)
    • October 2009 (1)
    • September 2009 (1)
    • August 2009 (1)
    • July 2009 (2)
    • April 2009 (2)
    • February 2009 (1)
    • January 2009 (2)
    • December 2008 (1)
    • October 2008 (1)
  • Pages

    • About / Contact

2008, © Daniel Mircea