Search Regex
[resolved] Change Permalinks: Post content regular expression (1 post)

  1. Robert
    Posted 1 year ago #

    Thought I'd share this solution for updating links in posts after changing the permalink structure. I search the web for hours looking for the correct regular expression and figured it out by using the Yoast .htaccess redirect rule.

    I changed my permalink structure from "Day and name" to just "Post name" in WordPress and setup the .htaccess 301 redirect described by Yoast.

    That left nearly 1000 post content links across hundreds of posts that referenced the old "Day and name" URL format, e.g. http://mysite.com/2012/03/05/sample-post/

    The following Search Regex regular expression updated the post content URLs to the new "Post name" permalink structure:

    Search pattern:

    Replace pattern:

    Include the www if your primary domain is http://www.mysite.com

    The post link search and replace worked perfectly and saved countless hours of work!


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Search Regex
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic