The issue:

  • Cannot change Permalink structure to any one except Plain. Otherwise, the post will return 404.
  • Update any post will fail with message: “Updating Failed. The Response is Not a Valid JSON Response

The initial nginx config:

server {
    server_name example.com;
    ...

    root /var/www/wordpress;
    index index.php index.html;

    location / {
        try_files $uri $uri/ $uri.html =404;
    }

    ...
}

Finally I found that the root cause is that nginx cannot redirect subpath to wordpress.

Since the Plain permalink has no subpath but with query string only: `https://52.175.32.36/?p=123`, the above nginx config works fine. When we change the permalink structure, the above rule cannot handle the subpath routing.

So we should modify the above rule like this and restart nginx:

server {
    server_name example.com;
    ...

    root /var/www/wordpress;
    index index.php index.html;

    location / {
        # file ($uri) or directory ($uri/)? if not, redirect to /index.php + query string
        try_files $uri $uri/ /index.php?$args;
        index  index.html index.htm index.php;
    }

    ...
}

By coriva

Related Post

Leave a Reply

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