Saturday, January 5, 2013

WordPress SEO by Yoast and Nginx

Wordpress-SEO by Yoast is a great plugin for search engine optimization. It can generate XML sitemaps on the fly. While on Nginx, I found that I was getting 404 errors when trying to load the sitemap.

The solution was simple. We just need to pass the "sitemap name" as a URI to "index.php" which can be done by simply adding this to "server block":

rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
If you are already using Nginx with Wordpress friendly URLs, these steps are not necessary and redundant.

0 comments:

Post a Comment