Testing Regex for Sub-Directory Redirects

Category : Knowledge Share

Columbus Supply site launched a few weeks ago. The old site had a really dated URL structure that made anything other than a global redirect difficult.

But instead of just having a global redirect, we wanted to redirect a few of the product categories to their new, corresponding pages. However, we didn’t have time to map out everything or do one-to-one’s across the site.

Trista and I worked together to understand the current layout of their product category URLs and product URLs, then structured a redirect plan using Regex to redirect specific categories followed by a catch-all to get everything previously missed. The Regex 101 tool allowed us to troubleshoot our regex before entering it into WP Engine.

This tool helps figure out how to handle redirects for a site launching in a short amount of time, for multiple products and product category levels. Without enough time and/or too convoluted of a structure to do one-to-one redirects, Regex 101 can help.

In the WordPress site, use regular expression in WP Engine to redirect any level of categories to redirect old page URLs to the new, active ones. You can use Regex 101 to test regular expressions for redirecting URLs before running it in WP Engine. Regex 101 provides an explanation as you’re testing as to what your regular expression is covering and any issues that the expression may create.

Once testing in Regex 101 looks good, you can upload your expressions to WP Engine without having to worry about causing issues in the live WordPress site.

https://regex101.com/