• Resolved Robert

    (@kinderrwindstreamnet)


    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:
    #http://mysite.com/([0-9]{4})/([0-9]{2})/([0-9]{2})/#

    Replace pattern:
    http://mysite.com/

    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!

    http://wordpress.org/plugins/search-regex/

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