Skip to content

Commit

Permalink
fix: index.php being directly usable in routing
Browse files Browse the repository at this point in the history
Does not allow `/index.php` to be the basepath. This prevents having a duplicate
of each page:
- / !== /index.php/
- /some-route/example !== /index.php/some-route/example

Should make all search engine indexers a bit more happy.
  • Loading branch information
tomudding committed Jul 21, 2024
1 parent ccbd9ae commit 86b19b2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions module/Application/src/Router/LanguageAwareTreeRouteStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ public function match(
// Store the original base URL (likely only just set above).
$oldBaseUrl = $this->getBaseUrl();

// Do not allow direct access using /index.php. It is too difficult to properly configure this in NGINX, as we
// want to keep using the Laminas-generated 404 page and not a generic NGINX 404 page.
if (str_starts_with($oldBaseUrl, '/index.php')) {
return null;
}

// Get the path from the URI, strip the base from it, and finally split it on `/`s.
$uri = $request->getUri();
$strippedPath = ltrim(
Expand Down

0 comments on commit 86b19b2

Please sign in to comment.