Back to the knowledgebase

How do I set up a redirect that matches multiple similar URLs?

Standard redirects match one specific URL exactly. If you need a single redirect to handle a range of similar URLs- for example, when migrating a whole section of a site where dozens of URLs share the same structure- Retour supports pattern-based matching using regular expressions.

When pattern matching is useful
Pattern matching is most useful for large-scale URL restructures. For example, if your old site used URLs like /news/2023/article-title and your new site uses /blog/article-title, a pattern redirect can handle the entire news section in one rule rather than requiring a separate redirect for every article.

How to set up a pattern redirect
When creating a redirect, change the Match Type setting from Exact Match to Regex Match. In the Source URL field, enter a regular expression pattern that describes the range of URLs to match. In the Destination URL, you can reference captured parts of the source URL using $1, $2, and so on.

A note on complexity
Pattern-based redirects require familiarity with regular expressions and should be tested carefully before being used on a live site, as a poorly written pattern can unintentionally match URLs you did not intend to redirect. If you need help setting up a complex pattern redirect, contact your site administrator.

Similar articles