Welcome to Centmin Mod Community
Register Now

Sysadmin Help with changing permalinks > nginx rewrite

Discussion in 'System Administration' started by upgrade81, Oct 16, 2019.

  1. upgrade81

    upgrade81 Premium Member Premium Member

    266
    16
    18
    Sep 5, 2016
    Italy
    Ratings:
    +27
    Local Time:
    6:27 AM
    1.17
    10.3
    Someone would be kind to tell me the necessary rewrite for nginx, to change the permalinks

    from:
    /%category%/%postname%/%post_id%

    to:

    /%category%/%postname%-%post_id%

    Thanks to those who give me the tip
     
  2. eva2000

    eva2000 Administrator Staff Member

    44,804
    10,216
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,834
    Local Time:
    2:27 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    For wordpress ? try_files in place takes care of all variations of permalinks so no changes needed.
     
  3. upgrade81

    upgrade81 Premium Member Premium Member

    266
    16
    18
    Sep 5, 2016
    Italy
    Ratings:
    +27
    Local Time:
    6:27 AM
    1.17
    10.3
    Hi yes I know this, but I changed the structure of the permalinks replacing / with - at the end of url
    So I was looking for the rule to apply on the nginx vhost configuration.
     
  4. upgrade81

    upgrade81 Premium Member Premium Member

    266
    16
    18
    Sep 5, 2016
    Italy
    Ratings:
    +27
    Local Time:
    6:27 AM
    1.17
    10.3
    I should have succeeded for those who need it here is the regex.

    Code:
    rewrite "^/([a-zA-Z0-9-]+)\/([a-zA-Z0-9-]+)/([0-9]+)" https://domain.com/$1/$2-$3 permanent;
    
     
  5. eva2000

    eva2000 Administrator Staff Member

    44,804
    10,216
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,834
    Local Time:
    2:27 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    so try_files natively doesn't work ? or you mean you want to redirect old permalinks to the new permalinks format ?

    I thought you meant for existing links only !