WordPress Permanent Link return 404 on Nginx Issue

Issue

Environment is Linux, Nginx, Mysql and PHP. Very standard LEMP setup. With latest WordPress installation. The issues happens when change post permanent format to %postname% in wordpress settings. The server will return 404 when click the link. Or simply put, it can’t find the post.

Solution

The problem is about the Nginx config about the site, which located (normally) at /etc/nginx/sites-available.

In the configuration file about your site, change or add this:


location / {
try_files $uri $uri/ /index.php?q=$uri$args;
}

reload nginx: sudo service nginx reload

Now the link should work.

Note: there are a lot of solutions about .htaccess file modification, which not apply to Nginx server, that is for Apache.

Leave a Reply

Your email address will not be published. Required fields are marked *