How to set up regex redirects in WordPress without breaking SEO

When a site’s structure changes, old addresses still live on in search results, bookmarks and other websites. A few well-written redirect rules keep them working.

Start with a list of old URLs

Before writing any rule, collect the addresses that matter. Export your old sitemap, check the pages report in Google Search Console and look at your analytics for pages that still get visits. Then write the new destination next to each one.

Look for patterns

If hundreds of URLs change in the same way, one regular expression can replace hundreds of single redirects. With a free plugin such as Redirection, add a new rule, switch on the regex option and use a pattern like this:

Source:  ^/old-listing/(.*)$
Target:  /listings/$1
Type:    301

The ^ anchors the match to the start of the path. The brackets capture whatever follows, and $1 places it in the new address.

Avoid the common mistakes

  • Do not send every old page to the home page. Visitors get lost, and search engines may treat it as a missing page.
  • Keep patterns narrow, so they do not catch URLs you meant to leave alone.
  • Handle special cases before general rules.
  • Redirect straight to the final address instead of chaining one redirect into another.

Test, then monitor

Try a sample of old URLs and confirm each returns a 301 and lands on the right page. Update your internal links and sitemap to use the new addresses. Over the next few weeks, check the 404 log and Search Console for anything you missed.

Arun S Chandran

Full stack developer in Kerala, India, focused on performance, security and clear communication.

Got a problem to fix?