• 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
  • Inviting everyone to the UX test of a new security feature in the WP Toolkit
    For WordPress site owners, threats posed by hackers are ever-present. Because of this, we are developing a new security feature for the WP Toolkit. If the topic of WordPress website security is relevant to you, we would be grateful if you could share your experience and help us test the usability of this feature. We invite you to join us for a 1-hour online session via Google Meet. Select a convenient meeting time with our friendly UX staff 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