WordPress and NGINX – permalinks are not working with ending slash

I don’t think you need this rewrite rule to add forward slash. WordPress will make redirect for you.

I’m using this code to debug redirection:

function wpse_287994_debug_redirect( $url ) {

    echo $url;
    die();
}

add_action( 'wp_redirect', 'wpse_287994_debug_redirect' );

When I’m trying to visit address http://example.com/lorem-ipsum (this page must exists) above script will output http://example.com/lorem-ipsum/ so redirection to address with forward slash is working.

My ngnix configuration looks like:

server {
  listen *:80;
  server_name           example.com;
  root                  /var/www/example;

  access_log            /var/log/nginx/access.log;
  error_log             /var/log/nginx/error.log;

  index index.php index.html;

  location / {
    # try to serve file directly, fallback to index.php
    try_files $uri $uri/ /index.php?$args;
  }

  location ~ \.php$ {

    include fastcgi.conf;

    fastcgi_pass 127.0.0.1:9070;
  }
}

In Nginx rewrites are already made by this part try_files $uri $uri/ /index.php?$args;. This part mean something like that.

For location beginning with / character try to load file from file system and if there is no such a file rewrite to index.php with arguments.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)