This is a common site migration redirection issue. We want to change the WordPress blog posts from having .com/blog/post-name-here/ in the URL to the single post URL being just .com/post-name-here/ But we often still have a .com/blog/ landing page AND it is often still paginated like .com/blog/page/2/
So the challenge is creating a 301 Redirect Rule that attacks the single posts URLs but leaves our blog landing page and pagination alone.
Here is the solution we’re running. Big thanks to my friend Josh Hull for helping guide my regex newb-ness towards this solution.
Source:^/blog/((?!page)[^/]+)/?$
Destination:https://limecuda.com/$1/
If you want to see and test, here is a great tool where you can modify and see if you are capturing or leaving the right URLs. We are escaping the slashes using this tool but in WPENGINE I didn’t need to have them escaped.
https://regex101.com/r/fUNjIp/5
Here’s what this blog redirect rule looks like in WPENGINE’s redirect manager