Support » Plugins and Hacks » [Resolved] Change Permalinks: Post content regular expression

[Resolved] Change Permalinks: Post content regular expression

  • Robert


    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!


  • The topic ‘[Resolved] Change Permalinks: Post content regular expression’ is closed to new replies.