Master advanced URL matching with regular expressions to create powerful and flexible redirect rules.
Enable regex mode when creating redirects to unlock pattern matching capabilities:
Source URL: /blog/(\d+)/([^/]+)Target URL: /articles/$1-$2Regular expressions (regex) are powerful pattern-matching tools that allow you to match URLs based on patterns rather than exact strings. This enables dynamic redirects that can handle variable content like IDs, slugs, dates, and more.
(\d+)Matches one or more digits
([^/]+)Matches any character except forward slash
/?([^/]*)Makes a URL segment optional
(\d{4})/(\d{2})/(\d{2})Matches YYYY/MM/DD format
([^/]+)\.(html?|php)$Matches files with specific extensions
(.*)Captures everything (use carefully!)
Moving from WordPress to static site
/blog/(\d+)/([^/]+)/?/articles/$2-$1/blog/123/hello-world→/articles/hello-world-123/blog/456/react-tutorial/→/articles/react-tutorial-456Reorganizing dated content
/(\d{4})/(\d{2})/(\d{2})/([^/]+)/?/archive/$1/$4/2023/12/25/christmas-post→/archive/2023/christmas-post/2024/01/01/new-year-goals/→/archive/2024/new-year-goalsFlattening category structure
/category/([^/]+)/([^/]+)/?/topics/$2/category/tech/javascript→/topics/javascript/category/design/ui-patterns/→/topics/ui-patternsRemoving .html extensions
/([^/]+)\.html?$/$1/about.html→/about/contact.htm→/contactMoving from subdomain to path-based structure
^/(.*)$/blog/$1💡 Use with domain-specific conditions
/post-title→/blog/post-title/about→/blog/aboutUse named groups for better readability and maintenance:
Source: /blog/(?<id>\d+)/(?<slug>[^/]+)Target: /articles/${slug}-${id}blog(?=/\d+)Matches "blog" only if followed by "/digits"
(?<!old)/pageMatches "/page" not preceded by "old"
Use conditional patterns for complex routing logic:
/(mobile|m)\\.example\\.com/(.*)$Target: /mobile/$2Use RedirectFlow's built-in regex tester to validate your patterns before deployment:
Check for unescaped special characters (. + * ? ^ $ { } [ ] \ | ( ))
Make patterns more specific with anchors (^ for start, $ for end)
Verify parentheses placement and $1, $2 references in target
.Any character*Zero or more+One or more?Zero or one^Start of string$End of string\dAny digit\wAny word character\sAny whitespace[abc]Any of a, b, or c[^abc]Not a, b, or c()Capture group(?:)Non-capture groupa|ba or b{3}Exactly 3{3,5}3 to 5Start using regex patterns in your redirects to create powerful, dynamic routing rules.