Problem/Motivation MyREST SEO lacks a built‑in way to define simple SEO redirects (301/302). A small native feature for common redirect rules (old → new paths) would help small sites without installing Redirect. Must not conflict with Redirect if present.
Proposed resolution

Implement an EventSubscriber on KernelEvents::REQUEST with early priority to apply configured redirects before controller resolution.

Add a config UI at /admin/seo/redirects to manage rules (source, target, 301/302, enabled; optional regex; optional language/site contexts).

Add proper cacheability: contexts (languages:language_interface, url.path), tags (config:myrest_seo.redirects), and safe short‑circuiting only on match.

Compatibility: if Redirect module is enabled, our subscriber is disabled by default (toggle in settings).

Tests: finish/extend the current routes functional test and add Kernel/Functional tests for redirect behavior.
Tasks

[ ] Config schema: myrest_seo.redirects (rule list) and myrest_seo.settings.redirects_enabled.

[ ] EventSubscriber: src/EventSubscriber/RedirectSubscriber.php applying redirects.

[ ] Admin form: src/Form/RedirectsForm.php at /admin/seo/redirects (permission: administer myrest_seo; _admin_route: TRUE).

[ ] Cacheability: add contexts/tags; ensure no cache poisoning.

[ ] Tests: Kernel test for matcher; Functional test verifying 301/302 redirect and that feature can be toggled; ensure no conflict when Redirect module is present.

[ ] Docs: README section (feature + coexistence note).

[ ] CI stays green (PHPCS, phpstan‑drupal, PHPUnit).
Acceptance criteria

[ ] Rules are editable via /admin/seo/redirects and stored in exportable config.

[ ] Matching requests return correct 301/302 to target.

[ ] With Redirect module enabled and the toggle off, no duplicate redirects occur.

[ ] Tests green on drupal.org CI; PHPCS/phpstan‑drupal pass.
Testing instructions
1)
Create /old → /new (301); visit /old → expect 301 to /new.
2)
Disable the feature; /old should no longer redirect.
3)
Enable Redirect module; confirm our subscriber is disabled (no duplication).

Issue fork myrest_seo-3567281

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

sergeydruua created an issue. See original summary.

  • sergeydruua committed be269008 on 1.0.x
    Issue #3567281: Redirect rules MVP via EventSubscriber; admin UI...
sergeydruua’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

sergeydruua’s picture

Status: Fixed » Closed (fixed)