A person following an incomplete link to a Drutopia site is redirected to the correct page

Created on 21 September 2023, about 1 year ago
Updated 11 October 2023, about 1 year ago

Problem/Motivation

The last character or two is left off a link by a person copy-pasting it to a friend.

An e-mail program wraps a line at a character limit and cuts a link in half.

The link someone was trying to share is:
https://example.com/wow-this-is-an-amazing-page-you-have-to-see-it

If it gets to someone as https://example.com/wow-this-is-an-amazing or https://example.com/wow-this-is-an-amazing-page-you-ha and there are no other pages on the site except that one with a path alias that starts in that way, the person following that link should absolutely be redirected to the full link, to that only matching page.

Even if the link reaches someone as https://example.com/wow if there is only one node or other page on the website with a URL alias that starts with 'wow' the visitor should be sent to that page, with the URI expanded (redirected) to the complete path.

Steps to reproduce

Truncate a URL and paste it in your browser to try to visit it. You will get an unhelpful 404 even though the website should know darn well where you are trying to go.

Proposed resolution

I know WordPress has done this forever, built into their `redirect_canonical` filter. It should not be hard to do for Drupal, and i'd be very surprised if there's no module, at least for Drupal 7, but i haven't found it yet.

Drupal module to guess the right path if none match completely, but the first part does match. Drupal redirect to best match URL. Drupal redirect to full path alias if incomplete start is the same.

https://www.drupal.org/project/search404 β†’ covers a lot of the same use case, but is much less effective if the cut off is relatively early but the beginning of the alias is still unique. Ideally our hypothetical module runs first with a super-quick match on existing aliases (and probably existing redirects too) and if nothing is found we fall back to search404.

Remaining tasks

Find this module or create it.

User interface changes

People get to the page they are looking for more often, not even having to know they didn't have the complete URL.

API changes

None.

Data model changes

None.

✨ Feature request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mlncn Minneapolis, MN, USA

Live updates comments and jobs are added and updated live.
  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024