How to set up 301 redirects for pages in nginx

July 17, 2011

When I moved my blog from Tumblr to Jekyll recently, I was left with the issue of several old Tumblr URLs being around on the internet, and google especially, which clearly would have negatively impacted on people's ability to find my content. Man of the posts out there at the moment tend to talk about more general redirects - moving all traffic to or from a www. prefix for example, but in order to do specific page redirects the principles are the same

server {
    listen 80;

    root /path/to/root/dir;

    location / {
        allow all;

    rewrite ^/path/to/old/2948506$ permanent;