Reputation: 94
I had a Wordpress blog where the individual post URLs were set up like this: http://blogname.com/knowledge-communities/2013/01/blog-title
I recently refreshed the site and they are now set to this: http://blogname.com/blog-title
So if a user finds a link to an old blog post(through Twitter or other social media), I want to redirect them to the new URL structure by removing the 'knowledge-communities' segment and the date segments(2013/01).
I have this so far which is removing the 'knowledge-communities' segment, but I can't find a way to remove the date segments- /2013/01.
RewriteRule ^knowledge\-communities/(.*) /$1 [R=301,L]
Any help is appreciated.
Upvotes: 0
Views: 355
Reputation: 1478
You can modify your regex to catch the item after two groups of digits :
RewriteRule ^knowledge\-communities/[0-9]+/[0-9]+/(.*) /$1 [R=301,L]
Upvotes: 1