Question

WordPress SEO causing error on Nginx server

  • Posted on July 19, 2014
  • g.dooceAsked by g.dooce

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:

http://gyazo.com/6c2cd53386844b3862a8dbb5b58a5407

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.

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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.