WordPress SEO causing error on Nginx server

Posted July 19, 2014 4.1k views

Hi there

I’m having a little problem after migrating from shared hosting (Apache) to a 512mb Droplet running a LEMP stack (I used the excellent EasyEngine to create a WordPress site).

After following the guide over at EasyEngine for migration I managed to import everything correctly.
I then pointed the DNS to my Droplet (changed nameservers etc) and was all set to go.

Weirdly, I can access my wp-admin area of my site and everything about it, but when I try to load my homepage or a specific article - I get this:

After carefully deactivating each and every plugin I honed the error down to Yoast’s WordPress SEO. After deactivating that, the site functions perfectly, however, that plugin is an essential part of my site so I have to get it all working together.

The problem is, I do not know where the error lies.

I have examined my Nginx config files both on /etc/nginx/sites-available & /etc/nginx/sites-enabled as well as the default nginx config files but I cannot seem to find a solution.

I have transferred over my sitemap which Yoast creates, and it works fine. But that begs the question - what part of the plugin is causing the error on Nginx?

It’s literally just that problem and otherwise the site functions perfectly (or at least I think so!)

Any help would be massively appreciated.

1 comment

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

It seems that Yoast’s WordPress SEO requires rewrite rules and writes an Apache style .htaccess file in the site’s root directory.

In your Niginx config (likely /etc/nginx/sites-enabled/default), try adding the following in side of your server block:

rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;

See here.