Skip to content

URL::enforceTrailingSlashes causes 404 on home page of site with url prefix #14024

@Balletie

Description

@Balletie

Bug description

Tried setting up a home page on a multisite-enabled project (in trial mode on my local machine), but got 404 constantly. Eventually found out that multi-site is not needed to reproduce, but the site url needs a path prefix like /en/ or similar.

How to reproduce

Minimal example, multi-site is not needed.

Start a new site with statamic new, then go to site settings and changing the site url to e.g. /en/. Copying sites.yaml below:

default:
  name: '{{ config:app:name }}'
  url: /en/
  locale: '{{ config:app:locale }}'

home page at /en/ still works.

Then add to boot method in AppServiceProvider:

    public function boot(): void
    {
        URL::enforceTrailingSlashes();
    }

and it stops working.

Logs

Environment

Environment
Application Name: Statamic
Laravel Version: 12.52.0
PHP Version: 8.4.16
Composer Version: 2.8.8
Environment: local
Debug Mode: ENABLED
URL: trailing-slashes-bug.test
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: sqlite
Logs: stack / single
Mail: log
Queue: sync
Session: file

Storage
public/storage: NOT LINKED

Statamic
Addons: 1
Sites: 1
Stache Watcher: Enabled (auto)
Static Caching: Disabled
Version: 6.3.2 Solo

Statamic Addons
statamic/ssg: 4.0.0

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions