{"id":31542592,"url":"https://github.com/baikho/drupal-redirect_regex","last_synced_at":"2026-05-14T23:05:16.164Z","repository":{"id":316426824,"uuid":"1063321474","full_name":"baikho/drupal-redirect_regex","owner":"baikho","description":"Redirect Regex Module","archived":false,"fork":false,"pushed_at":"2025-09-24T14:00:00.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"1.x","last_synced_at":"2025-09-24T15:28:42.320Z","etag":null,"topics":["drupal","drupal-module"],"latest_commit_sha":null,"homepage":"https://www.drupal.org/project/redirect_regex","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/baikho.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-24T13:17:57.000Z","updated_at":"2025-09-24T14:48:24.000Z","dependencies_parsed_at":"2025-09-24T15:28:45.258Z","dependency_job_id":"e20de3a7-d127-43a9-b42f-2e347ace401f","html_url":"https://github.com/baikho/drupal-redirect_regex","commit_stats":null,"previous_names":["baikho/drupal-redirect_regex"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/baikho/drupal-redirect_regex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baikho%2Fdrupal-redirect_regex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baikho%2Fdrupal-redirect_regex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baikho%2Fdrupal-redirect_regex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baikho%2Fdrupal-redirect_regex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/baikho","download_url":"https://codeload.github.com/baikho/drupal-redirect_regex/tar.gz/refs/heads/1.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baikho%2Fdrupal-redirect_regex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278308618,"owners_count":25965654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["drupal","drupal-module"],"created_at":"2025-10-04T11:59:23.031Z","updated_at":"2025-10-04T11:59:30.837Z","avatar_url":"https://github.com/baikho.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Redirect Regex Module\n\nThis module extends the [Redirect](https://www.drupal.org/project/redirect) module to support regex pattern matching in addition to exact path matching using the redirect entities.\n\n## Installation\n\nAdd to `composer.json`:\n```\n{\n  \"repositories\": [\n    {\n      \"type\": \"vcs\",\n      \"url\": \"https://github.com/baikho/drupal-redirect_regex\"\n    }\n  ],\n  \"require\": {\n    \"drupal/redirect_regex\": \"1.0.0-alpha5\"\n  }\n}\n```\n And run:\n```\ncomposer require drupal/redirect_regex:1.0.0-alpha5\n```\n\n## Architecture\n\nThis module follows the same architectural patterns as the redirect module:\n\n- **Extends RedirectRepository**: The `RedirectRegexRepository` extends the `RedirectRepository` class\n- **Service Override**: Uses a service provider to override the `redirect.repository` service\n- **Convention-Based**: Regex redirects are identified by source paths starting with `regex:`\n- **Backward Compatibility**: All existing redirect functionality continues to work unchanged\n\n## How It Works\n\n1. **Service Override**: The module overrides the `redirect.repository` service to use `RedirectRegexRepository`\n2. **Fallback Logic**: `RedirectRegexRepository::findMatchingRedirect()` first checks for regular redirects, then falls back to regex redirects\n3. **Efficient Querying**: Only regex redirects (those with `regex:` prefix) are loaded from the database, not all redirects\n4. **Multilingual Support**: Patterns are tested against paths both with and without language prefixes\n5. **Regex Convention**: Regex redirects are stored as normal redirect entities but with source paths prefixed with `regex:`\n6. **Pattern Extraction**: The actual regex pattern is extracted by removing the `regex:` prefix\n\n## Creating Regex Redirects\n\nTo create a regex redirect:\n\n1. Go to `/admin/config/search/redirect/add`\n2. Set the **From** field to: `regex:your-pattern`\n   - Example: `regex:user\\/\\d+\\/profile`\n3. Set the **To** field to the redirect target\n4. Save the redirect\n\n**Important Notes:**\n- **Do NOT include a leading slash** in the regex pattern (e.g., use `user\\/\\d+\\/profile`, not `\\/user\\/\\d+\\/profile`)\n- The redirect system automatically strips leading slashes before matching\n- Remember to escape backslashes in the admin interface (type `\\/` for literal `/` in regex)\n- For redirects from existing routes, enable \"Allow redirects from aliases\" in redirect settings\n- **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`)\n\n## Integration Points\n\nThis module seamlessly integrates with:\n- **GraphQL**: Route queries automatically check both redirect types\n- **HTTP Redirects**: Request subscribers use the unified repository\n- **Admin Interface**: Uses existing redirect admin pages\n- **API**: Any code using `redirect.repository` gets regex support automatically\n\n## Dependencies\n\n- `redirect:redirect` (\u003e=1.12) - provides the redirect entities and admin interface\n\n## Usage\n\n1. Enable the module: `drush en redirect_regex`\n2. Create regex redirects using the standard redirect admin interface with the `regex:` prefix\n3. All existing redirect functionality continues to work\n4. GraphQL route queries now support regex redirects automatically\n\n## Examples\n\n| Source Path | Redirect Target | Description |\n|-------------|----------------|-------------|\n| `regex:blog\\/\\d+\\/.*` | `/blog/archive` | Redirect old blog URLs to archive |\n| `regex:user\\/\\d+\\/profile` | `/user/profile` | Redirect user profile URLs |\n| `regex:page\\/old\\/([0-9a-z]+)` | `/page/new-page` | Redirect old page URLs with alphanumeric IDs |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaikho%2Fdrupal-redirect_regex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaikho%2Fdrupal-redirect_regex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaikho%2Fdrupal-redirect_regex/lists"}