Drupal is a registered trademark of Dries Buytaert
drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). eca 3.1.1 Minor update available for module eca (3.1.1). layout_paragraphs 2.1.3 Minor update available for module layout_paragraphs (2.1.3). ai 1.3.3 Minor update available for module ai (1.3.3). ai 1.2.14 Minor update available for module ai (1.2.14). node_revision_delete 2.0.3 Minor update available for module node_revision_delete (2.0.3). moderated_content_bulk_publish 2.0.52 Minor update available for module moderated_content_bulk_publish (2.0.52). klaro 3.0.10 Minor update available for module klaro (3.0.10). klaro 3.0.9 Minor update available for module klaro (3.0.9). layout_paragraphs 2.1.2 Minor update available for module layout_paragraphs (2.1.2). geofield_map 11.1.8 Minor update available for module geofield_map (11.1.8).

redirect_regex

15 sites Security covered
View on drupal.org

This module extends the Redirect module to support regex pattern matching in addition to exact path matching using the redirect entities.

Features

  • Extends RedirectRepository: The RedirectRegexRepository extends the RedirectRepository class
  • Service Override: Uses a service decorator to override the redirect.repository service
  • 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:

  1. Go to /admin/config/search/redirect/add
  2. Set the From field to: regex:your-pattern
  3. Example: regex:user\/\d+\/profile
  4. Set the To field to the redirect target
  5. 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/profile and en/user/123/profile)

Dependencies

Similar projects

Activity

Total releases
6
First release
Sep 2025
Latest release
6 months ago
Release cadence
0 days
Stability
0% stable

Release Timeline

Releases

Version Type Release date
1.0.0-alpha5 Pre-release Sep 25, 2025
1.0.0-alpha4 Pre-release Sep 24, 2025
1.0.0-alpha3 Pre-release Sep 24, 2025
1.0.0-alpha2 Pre-release Sep 24, 2025
1.0.0-alpha1 Pre-release Sep 24, 2025
1.x-dev Dev Sep 24, 2025