Rewrite URL to remap WordPress Permalink

I'm moving my WordPress site to a new host, and in the process I want to make a one time change to the Permalinks. I want to rewrite the URLs from /2015/11/sample-post/ to /sample-post/ but how can I accomplish that?

Answers 2

  • The most efficient way to accomplish this would be to change the structure to /%postname%/ and add a 301 redirect to your .htaccess file for the old structure:

    RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/(?!page/)(.+)$$3

    Change to your domain and add the redirect above the # BEGIN WordPress directive so it won't be removed if WordPress updates the file.

    EDIT- redirect /yyyy/mm/dd/postname

    RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(?!page/)(.+)$$4

Related Questions