Right now I have a bunch of old blog posts that I need to update to the new url structure. I added /blog/ to all of the new url, and old existing links just have the old format without the /blog/ piece of the url. The former pages on the blog had no unique piece to their url to match them together so this is proving difficult for me to redirect.

Is there a way to use regex/or something else to create a simple redirect that will capture all links for each blog page, for example one of the old links looks like:


I want it to become:


I also want all urls that contain the piece /example-here/ to redirect to /blog/example-here

How would I do that?

Thank you!

  • Seems more like general PHP question for 301 redirect processing, rather than a wordpress question. – klewis Aug 2 '18 at 0:52

You could do this a couple of ways,

if you have access to your .htaccess-file & are comfortable editing it:

You can workout a regex to do it...

RedirectMatch /example-here/(.+) http://www.exapmles.com/blog/example-here/$1 [R=301,L]

or use a redirect plugin to create the redirects you want. here's a couple options:

  • Thank you for the response. I am still running into issues with these solutions for some reason. I setup the regex just like you said (using the redirection plugin), but it is throwing the url into a loop where it loads a bunch of consecutive url's and gives me an error saying "Redirected you too many times". – Kyle Aug 8 '18 at 17:31
  • That usually means you have a redirect elsewhere in the system. It's often a sub-domain redirect which hasn't been removed completely. For instance, if you have one redirect pointing stackexchange.com to www.stackexchange.com then another redirecting www.stackexchange.com to stackexchange.com you're going to see problems. What folder does the site live in? What is the www-root folder? Are there sub-domains on the server? What are the wordpress-address & site-address urls in wp-admin >> settings >> general? & lastly, what else is in your .htaccess file? – admcfajn Aug 8 '18 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.