0

The situation is this:

I moved my site a while ago, and I changed http://www.getridofthings.com/blog to http://www.getridofthings.com/blogs/ to include more authors with their own blogs. The problem now, is that Google Webmaster Tools is telling me I have a bunch of 404s. We deleted the old blog posts because they were poor quality, but I want to collect all of the incoming links from those various blog posts and direct them simply to the /blogs/ url.

How do I write this rule in NGINX? I've tried many methods, and I keep getting "too many redirects" or "redirect loop" errors.

1 Answers1

0

This should do the trick.

server {
  listen: 127.0.0.1;
  server_name: example.com;

  rewrite ^/blog/(.*)$ /blogs/$1 redirect;
}

It works by saying that it wants /blog/ to be at the beginning of the url. If there's anything after the /, it will be stored in $1 which is appended to /blogs/. There are no redirect loops because /blogs/ cannot match those conditions.

Redirects that will happen:

  • /blog/ to /blogs/
  • /blog/blog-article-1/ to /blogs/blog-article-1/
clinton3141
  • 4,751
  • 3
  • 33
  • 46