Restore redirect to cacheable 301 response

Created on 16 May 2025, 22 days ago

Problem/Motivation

We recently received a recommendation from our SEO consultant that our URL shortener should be returning 301 "Moved permanently" responses instead of 302 "Found". I believe that this is intended to improve the SEO ran of the destination pages.

Looking through the issue queue, I learned that this module was originally designed in Drupal 6 to use 301 redirects and that in Drupal 7, this decision was reiterated several times.

https://git.drupalcode.org/project/shurly/-/blob/6.x-1.x/shurly.module?r...

I am guessing that the 302 redirect was accidentally introduced by relying on the default Symfony RedirectResponse behavior rather than passing in a 301 status code.

See https://git.drupalcode.org/project/shurly/-/commit/a14c890eec9d37c8647cb...

Steps to reproduce

Run the following command from a terminal:
curl -I https://example.org/abcd
Observe the following response:
HTTP/2 302

Proposed resolution

Use $status = 301 when creating the redirect response.

If the 302 response is intentional and this behavior should not be changed, the rationale should at least be documented.

πŸ“Œ Task
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States amanire

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