• The APS Catalog has been deprecated and removed from all Plesk Obsidian versions.
    Applications already installed from the APS Catalog will continue working. However, Plesk will no longer provide support for APS applications.
  • Please be aware: with the Plesk Obsidian 18.0.78 release, the support for the ngx_pagespeed.so module will be deprecated and removed from the sw-nginx package.

Resolved Nginx config for WordPress rewrite rules

Gabor H

Basic Pleskian
Hi,

How to configure Nginx, to make it work properly with WordPress rewrite rules correctly?

I've this in a domain's additional nginx directives:

if (!-e $request_filename) { rewrite ^.*$ /index.php last; }


But sometimes nginx struggling with the rewrite rules, I guess, because some pages are broken.
Pls help me to find the best nginx config for rewrite.

G.
 
Hi Gabor H,

Wordpress itself offers a guide with some standard configurations: => https://codex.wordpress.org/Nginx
Pls. note, that almost all issues with "broken" links are based on the fact, that when you use apache2 AND nginx, unique ".htaccess" - definitions are not correctly converted into nginx directives. Often enough, additional plugins require rewrites which are automatically added into the ".htaccess" - files, but the webmaster forgot that he/she uses niginx as well and the needed nginx directive is missing. :(

Plesk offers as well a wonderfull tool called "htaccess to nginx" - converter. You find this extension at the "Extension catalog" ( "Home > Extensions Management > Extensions Catalog" ), or at => htaccess to nginx at ext.plesk.com
 
Hi UFHH01,

Thanks for your reply.
I've finally sorted out the issues.

But, some broken pages are still exist.
Which is unfortunately an off-topic related issue.
A WP theme cookie(s) has long, or longer than needed validation time.
(some pages only loading in right order, when browser's cache+cookie deleted)

Is there any solution maybe, or do you know a solution maybe to control cookies invalidation via
Nginx?


Regards,
Gabor


Hi Gabor H,

Wordpress itself offers a guide with some standard configurations: => https://codex.wordpress.org/Nginx
Pls. note, that almost all issues with "broken" links are based on the fact, that when you use apache2 AND nginx, unique ".htaccess" - definitions are not correctly converted into nginx directives. Often enough, additional plugins require rewrites which are automatically added into the ".htaccess" - files, but the webmaster forgot that he/she uses niginx as well and the needed nginx directive is missing. :(

Plesk offers as well a wonderfull tool called "htaccess to nginx" - converter. You find this extension at the "Extension catalog" ( "Home > Extensions Management > Extensions Catalog" ), or at => htaccess to nginx at ext.plesk.com
 
This one below works best for me with nginx. Put it in Apache & nginx Settings -- Additional nginx directives

if (!-e $request_filename){
rewrite ^(.*)$ /index.php break;
}
 
Back
Top