Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Trailing Slash Laravel Package

fsasvari/laravel-trailing-slash

A small Laravel package for consistent trailing slashes in URLs. It provides middleware and helpers to add, remove, or enforce trailing slashes, helping avoid duplicate routes and SEO issues while keeping redirects and canonical URLs predictable.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Canonical URL policy as an explicit, owned decision. The package turns "do we use trailing slashes?" from a per-engineer habit into a configured rule enforced in one middleware. That is a product decision about how our URLs appear in search results, ads, emails, print collateral, and partner links — not a code-style preference.
  • SEO and analytics integrity for public-facing surfaces. A single page reachable at /pricing and /pricing/ splits backlink equity, duplicates content in crawl, and produces two rows in every funnel report. Trailing-slash normalization is the cheapest lever against that class of silent measurement error, and it protects campaign and referral attribution when inbound links are inconsistent.
  • Build vs. buy: this is a "buy the decision, not the code" case. The underlying behavior is a few dozen lines of middleware. The package's real value is that it is already named, versioned, MIT-licensed, and documented, so the team doesn't re-debate the implementation each time a new service or route group appears. Treat adoption as a small dependency purchase with a known exit cost, not an architecture commitment.
  • Prioritization input for platform/migration work. If the roadmap includes a replatform, a marketing site launch, a CDN cutover, localization prefixes (/en/...), or a legacy URL inventory import, slash normalization needs to land before those launches — retrofitting it after links are published and indexed means permanent redirects we can never remove.
  • Use cases where it earns its keep: public marketing/content sites, sites migrating from WordPress or other slash-trailing CMSs, public sites with heavy offline/print/QR link distribution, and multi-brand or multi-domain setups where link hygiene is inconsistent across teams.
  • Use cases where it does not: JSON APIs and webhook endpoints (clients don't follow 301s reliably, and redirecting a POST is destructive), single-page internal tools with no external link surface, and anything where a CDN or web server already normalizes the path.
  • Roadmap signal, not a roadmap item. At 61 stars this is not a strategic dependency; it's a hygiene item that should be scoped inside whatever launch or SEO initiative is already funded, with an explicit owner.

When to Consider This Package

Consider it when:

  • We operate a public, indexable site and have (or plan to have) an explicit canonical URL convention that differs from whatever Laravel routes and inbound links currently produce.
  • We have measurable evidence of the problem: duplicate URLs in Search Console, split sessions in analytics for the same page, or 404s/soft-404s from inbound links with the "wrong" slash.
  • We are migrating from a platform with the opposite convention and need a single, reversible place to enforce the mapping rather than scattering redirects across route files.
  • The team wants the policy enforced centrally with config, and wants tests around it.
  • We can accept the maintenance profile: a small, low-traffic, MIT-licensed dependency we may end up vendoring.

Look elsewhere (or just build it) when:

  • The site is API-first or internal-only. Redirecting non-GET traffic is a footgun; JSON clients and webhook providers do not consistently follow redirects, and some will downgrade or drop the method.
  • The infrastructure layer already owns this. Nginx, a CDN, or a load balancer can normalize slashes before PHP boots — cheaper, faster, and it protects requests that never reach the app. Adding middleware on top creates two sources of truth.
  • We need broader URL canonicalization than slashes: host casing, www vs apex, HTTP→HTTPS, index.html stripping, locale prefixes, tracking-parameter stripping. This package does one dimension; adopting it may create a false sense that "URLs are handled."
  • Scale of the problem is trivial — a handful of legacy URLs is better served by explicit redirects or a full redirect-map package than by a global middleware touching every request.
  • Dependency risk outweighs benefit: 61 stars implies effectively one maintainer and a low bus factor. For a package this small, the honest comparison is our own tested middleware against a pinned, vendored copy. Either is defensible; what is not defensible is adopting it without deciding who owns it.
  • Middleware ordering is fragile in our stack (signed URLs, auth, session, Livewire/Inertia, cached responses). Redirect-before-auth and signed-URL handling need explicit verification before rollout.

Conditions to attach to adoption: restrict to GET/HEAD, use permanent (301) redirects with intent to keep them permanent, confirm query-string preservation, verify behavior behind the CDN/proxy, add coverage for signed URLs and authenticated routes, and record the chosen convention in our URL/linking guidelines so content and marketing teams stop producing both variants.

How to Pitch It (Stakeholders)

For executives: This is a small, free, MIT-licensed component that makes our web addresses consistent — one canonical form per page instead of two. The business reason is measurement and search performance: when the same page is reachable at two addresses, analytics reports it twice, inbound links and search ranking signals are split, and campaign attribution gets noisier. Fixing it is cheap now and gets more expensive after a launch, because published links can't be recalled. Cost is low and contained: no vendor contract, and the fallback if the package is abandoned is roughly a day of engineering to replace it with equivalent in-house code. I'd fund it as a line item inside an already-planned site or SEO initiative, not as a standalone project — and only after we've confirmed we actually have the problem, which a short check of our analytics and search console will tell us.

For engineering: We're standardizing slash handling in one middleware with configuration, tests, and a documented convention, instead of relying on how each developer happens to write links. Scope is deliberately narrow: GET/HEAD only, permanent redirects, query strings preserved, and we verify behavior behind the CDN before it ships. Known risks are middleware ordering and interactions with signed URLs and authenticated routes — those get explicit test coverage. The dependency is tiny and single-maintainer, so we pin the version, keep the middleware behind our own thin wrapper, and retain the option to vendor or rewrite it in an afternoon if upstream goes quiet. The deliverable is the policy and its tests, not the package.

Ask: a decision on the canonical convention (with-slash or without), an owner for the linking guideline that follows from it, and a slot in the current launch/SEO workstream to implement and verify it.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console