• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

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