Repository navigation
Redirect item links to the item's current URL when it moved projects - #385
Merged
Cannonb4ll merged 1 commit intoOct 15, 2026
Merged
Conversation
When an item is not found in the requested project, fall back to looking it up by slug, then by the ID its slug starts with, and redirect to its current URL. Applies to both the HTML and .md item URLs.
Member
|
I agree with the 302 to be honest here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When an item is moved to another project, its old link (e.g.
/projects/1-general/items/5-coupons) returns a 404 because the item is only looked up inside the project from the URL.This adds a fallback in
ItemController::findItem():5in5-coupons).When the resolved item's current URL differs from the requested one, the request is redirected to
view_url(ormarkdown_urlfor.mdURLs). The fallback usesItem::visibleForCurrentUser(), so private items and items in private projects still return a 404.Open question: 302 or 301?
The redirect currently uses Laravel's default 302. A 301 is better for SEO, but browsers cache 301s indefinitely: if an item is moved from project A to B and later back to A, a cached A→B redirect plus the live B→A redirect would send visitors in a loop. I've left it at 302. Happy to switch to 301 if you prefer that trade-off.
Tests
.md)