Wordpress permalink redirect issue

Discussion in 'Apache' started by vexx, Aug 7, 2017.

  1. #1
    I recently changed my permalink structure and I'm in a bit of a pickle. The original permalink structure was /%postname%-%post_id%/ and I wanted to change it to /%postname%/.

    The rule is something like this

    RedirectMatch301^/dir/([^/]+)-(\d+)/$ http://example.com/dir/$1
    Code (markup):


    While the above code works, I encountered a problem where some articles that end in digits, are incorrectly redirected and the site gives an error. For example: www.example.com/best-video-converters-windows-10/. The rule cuts away the 10 bit, making the article 404. I found a workaround by using a regex limiting the number of chars and the code is:

    RedirectMatch301^/dir/([^/]+)-(\d+){3,}/$ http://example.com/dir/$1
    Code (markup):


    And this code works...unless the article doesn't end in a year or something. Example: www.example.com/best-movies-2017/

    Bottom line, I have no idea how to get around this and I need a bit of help :)
     
    vexx, Aug 7, 2017 IP