skip to Main Content

I have a lot of posts on my site, and I want to add the number “1” to the end of the URLs of all my posts at once, and I also want RankMath automatic 301 redirection from the previous URLs to the new URLs, how to do this?

2

Answers


  1. First you update your permalink structure inside the Dashboard -> Settings -> Permalinks. Modify the permalink structure add the number “1” to the end of the URL. This is for your first issue.

    Login or Signup to reply.
  2. You could use WP CLIs wp db search-replace method, with the --regex flag.

    wp search-replace 'https://example.com/([^/]+)/?$' 'https://example.com/$1/1' --regex --all-tables
    

    This should roughly be your WP CLI command.

    Make sure to do wp db export first to save a copy of your DB incase this does not work as expected.

    DOCs: https://developer.wordpress.org/cli/commands/search-replace/

    Note: this will only replace your URLs, not change any logic. So WordPress might not find the pages anymore, without implementing some logic like the one explained by the user Free Helper’s solution.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search