How to fix the Nginx 404 not found error when WordPress is not installed in the root directory

Sometimes you need to install and access WordPress in a subdirectory instead of the root directory (where your main site is served with Nginx).

If you get the Nginx 404 not found error when accessing WordPress, add the following code in the virtual host file (eg: /etc/nginx/sites-available/mysite) to solve the problem.

NOTE: Replace yoursubdirectory with the name of the subdirectory where WordPress is installed.

Bruno Bastos

I'm a developer specialized in building web applications, focused on applying productive habits, willing to help and learn from this blog.