The correct nginx WordPress rewrite config

A while ago I was migrating my WordPress site from Apache to Lighttpd and then from Lighttpd to nginx. While in the first case it was pretty straightforward, I had some problems when adapting my Lighttpd rewrite rules to nginx.

Apart from WordPress permalinks, I also had some custom rewrites for easyfileshop and download monitor plugins. After checking a bunch of blog posts about nginx rewrite rules for WordPress, I ended up with a borked config file and had to ask for help on #nginx IRC channel. The nice people there told me about two really good pages describing nginx's DO's and DON'Ts: nginx pitfalls and IfIsEvil. It turned out I had collected all the nginx DON'Ts from various blogs.

Ultimately I managed to fix my configuration and remove the ugly stuff out of it. Now it works perfectly and looks like that:


[/raw]Note the lines in bold - that's actually all what you need for WordPress permalinks to work. Remember: if is evil, and you definitely don't want it here.

Martin is the founder of MultiMerch who has dedicated his life to building great products.