404 Errors driving you nuts?

If you’ve taken advantage of Plesk Onyx as a control panel for your hosting platform you’ll probably be familiar with how NGINX readily available to use and the speed advantages that can give you.

When you install WordPress all seems to go well, but then you write your first post and find permalink don’t work as expected, or more accurately that you get a 404 error when you try to navigate to your post.

A quick Google reveals that there are quite a few answers which vary from making server wide changes to a few lines.  The majority also seem to assume that WordPress will be installed within the site root, i.e. https://yourdomain.com is the home to your WordPress installation, but what if it isn’t?

Thankfully, it can be resolved with a few lines within the Additional NGINX Directives section of your Plesk control panel.

Assume your WordPress blog is installed in the snappily named “blog” directory of your web site, i.e https://gohostinguk.com/blog/

Log into Plesk and click on the Apache and Nginx settings icon.

In the page that loads find the  Additional NGINX Directives section

Enter the following text:

# if filename doesn't exist, take the request and pass to wordpress as a parameter
if (!-e $request_filename) { 
    rewrite ^/blog/(.+)$ /blog/index.php?q=$1 last;

location /blog { 
    try_files $uri $uri/ /blog/index.php?$args;

# Add trailing slash to */wp-admin requests.
rewrite /blog/wp-admin$ $scheme://$host$uri/ permanent;

We can’t take the credit for this one as it was found within the Plesk forums but it’s worked for a few people we know and if you’re currently running around pulling your hair out, we hope it works for you and saves you from premature baldness.