Preserve destination when creating redirect.

Created on 16 July 2025, about 2 months ago

Problem/Motivation

When using the 404 Redirects view provided by the redirect_404 module, users often apply filters (e.g., status=404) and pagination to browse long lists of missing URLs.
However, when clicking the “Add redirect” operation for a specific row, the destination query parameter does not preserve these query parameters (filters, page, etc.).
As a result, after saving the redirect, the user is returned to the default view path, not the filtered/paginated context they were working in.

Steps to reproduce

1. Go to the 404 redirects view (e.g., /admin/reports/redirect/404)
2. Apply filters or navigate to a paginated page (e.g., ?status=404&page=2)
3. Click on “Add redirect” for one of the rows
4. Save the redirect
5. You are redirected to /admin/reports/redirect/404 — but not back to the page with filters/pagination applied

Proposed resolution

Update the destination query parameter in the “Add redirect” link to use \Drupal::request()->getRequestUri() instead of just the view path.
This ensures the full path and query string are preserved, so the user is returned to the correct filtered/paginated context after saving the redirect.

Remaining tasks

User interface changes

None visible directly in the UI, but behavior improves: users return to their filtered/paginated view after saving a redirect.

API changes

None

Data model changes

None

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇧🇾Belarus impol

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024