Daily Archives: January 11, 2012

WordPress with Nginx: Solve the 404 after changing permalinks structure

Today I tried to change my site’s permalinks, but I can’t visit all old posts with a 404 error. I searched for a solution and found that I can add following section in my vhost conf file under nginx configurations.

location / {
        ……
if (!-e $request_filename) {

rewrite ^(.*)$ /index.php?q=$1 last;
break;

        }
}
Then restart nginx and change the permalinks structure in wordpress. Everything goes on track now.