This module extends the Redirect module to support regex pattern matching in addition to exact path matching using the redirect entities.
Features
- Extends
RedirectRepository: TheRedirectRegexRepositoryextends theRedirectRepositoryclass - Service Override: Uses a service decorator to override the
redirect.repositoryservice - Compatible with GraphQL through the Redirect module
Examples
| Source Path | Redirect Target | Description |
|---|---|---|
regex:blog\/\d+\/.* |
/blog/archive |
Redirect old blog URLs to archive |
regex:user\/\d+\/profile |
/user/profile |
Redirect user profile URLs |
regex:page\/old\/([0-9a-z]+) |
/page/new-page |
Redirect old page URLs with alphanumeric IDs |
Query:
query MyQuery {
route(path: "/user/123/profile") {
... on RouteRedirect {
__typename
internal
redirect
status
url
}
}
}
Response:
{
"data": {
"route": {
"__typename": "RouteRedirect",
"internal": true,
"redirect": true,
"status": 301,
"url": "/node/1"
}
}
}
Creating Regex Redirects
To create a regex redirect:
- Go to
/admin/config/search/redirect/add - Set the From field to:
regex:your-pattern - Example:
regex:user\/\d+\/profile - Set the To field to the redirect target
- Save the redirect
Important Notes:
- Do NOT include a leading slash in the regex pattern (e.g., use
user\/\d+\/profile, not\/user\/\d+\/profile) - The redirect system automatically strips leading slashes before matching
- Remember to escape backslashes in the admin interface (type
\/for literal/in regex) - For redirects from existing routes, enable "Allow redirects from aliases" in redirect settings
- Multilingual Support: Patterns are tested against both the current path and the path with language prefix (e.g.,
user/123/profileanden/user/123/profile)
Dependencies
- Redirect module
Similar projects
- Regex Redirect - Uses regexes with named captures
Supporting organizations:
Development and maintenance
Project information
- Project categories: Developer tools, Search engine optimization (SEO), Site structure
- Ecosystem: Redirect
34 sites report using this module
- Created by baikho on , updated
Stable releases for this project are covered by the security advisory policy.
There are currently no supported stable releases.
Releases
1.0.0-alpha6
released 27 May 2026
Works with Drupal: >=10
Add ability to replace regex references and query strings
Install:
Development version: 1.x-dev updated 20 May 2026 at 09:27 UTC


