• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion
  • Please beaware of a breaking change in the REST API on the next Plesk release (18.0.62).
    Starting from Plesk Obsidian 18.0.62, requests to REST API containing the Content-Type header with a media-type directive other than “application/json” will result in the HTTP “415 Unsupported Media Type” client error response code. Read more here

Resolved NGINX and Wordpress

omexlu

Regular Pleskian
Hello,

I have trouble with NGINX and Wordpress rewrite, it works with my configuration but on wp-admin i have to many redirects:

My htaccess before:
Code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

My nginx directive:
Code:
if (!-f $request_filename){
    set $rule_1 1$rule_1;
}
if (!-d $request_filename){
    set $rule_1 2$rule_1;
}
if ($rule_1 = "21"){
    rewrite /. /index.php last;
}

Whats the problem here? I have generated this with the plesk extension.

Thanks
 
Hi omexlu,

if you experience issues ( because of caching- or any other other used wordpress - plugins ), you could add:

Code:
    if (!-e $request_filename) {
        rewrite /wp-admin$ $scheme://$host$uri/ permanent;
        rewrite ^(/[^/]+)?(/wp-.*) $2 last;
        rewrite ^(/[^/]+)?(/.*\.php) $2 last;
    }
 
Like that?:

Code:
if (!-f $request_filename){
   set $rule_1 1$rule_1;
}
if (!-d $request_filename){
   set $rule_1 2$rule_1;
}
if ($rule_1 = "21"){
   rewrite /. /index.php last;
}

if (!-e $request_filename) {
       rewrite /wp-admin$ $scheme://$host$uri/ permanent;
       rewrite ^(/[^/]+)?(/wp-.*) $2 last;
       rewrite ^(/[^/]+)?(/.*\.php) $2 last;
   }
 
Hi omexlu,

well, I recommend to use the "standart" - like for example:

Code:
    if (!-e $request_filename) {
        rewrite ^(.+)$ /index.php break;
        }

    if (!-e $request_filename) {
        rewrite /wp-admin$ $scheme://$host$uri/ permanent;
        rewrite ^(/[^/]+)?(/wp-.*) $2 last;
        rewrite ^(/[^/]+)?(/.*\.php) $2 last;
        }
 
Back
Top