WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Robert
    Member
    Posted 6 months 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:
    #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/

Reply

You must log in to post.

About this Plugin

About this Topic