Fix WordPress 404 Error on NGINX

Trying to use WordPress permalinks on NGINX can be very problematic to get working correctly. Since NGINX doesn’t support .htaccess files WordPress isn’t able to tell NGINX how to interpret the new permalink structure, thus resulting in a 404 error when trying to view any page other than the homepage. Since using pretty URL’s are very important for SEO (and just looking more professional) it’s quite important that you get it working correctly.

The fix for this error is surprisingly very easy to do!

Since you’re using NGINX I’ll assume that you know where your configuration file for your website is located.

All you need to do is add the following to the configuration file.

try_files $uri $uri/ /index.php?$args;

It needs to be inside of a root location stub, for example

location / {

location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
 expires max;

try_files $uri $uri/ /index.php?$args;

location ~ [^/]\.php(/|$) {
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 if (!-f $document_root$fastcgi_script_name) {
 return 404;

 fastcgi_index index.php;
 include /etc/nginx/fastcgi_params;

Now restart your NGINX server and try going to one of the pages you were receiving the 404 on previously, it should now load fine!

If you have any issues then leave a comment and I’ll try my best to get it working for you 🙂

Leave a Reply

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