Skip to content

Commit d12eb0e

Browse files
committed
Only serve recognized locales if the file exists.
1 parent db5f5d8 commit d12eb0e

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

cli/drivers/StatamicValetDriver.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,16 @@ public function frontControllerPath($sitePath, $siteName, $uri)
6969
$sitePathPrefix = ($isAboveWebroot) ? $sitePath.'/public' : $sitePath;
7070

7171
if ($locale = $this->getUriLocale($uri)) {
72-
// Force trailing slashes on locale roots.
73-
if ($uri === '/' . $locale) {
74-
header('Location: ' . $uri . '/'); die;
72+
if ($this->isActualFile($localeIndexPath = $sitePathPrefix . '/' . $locale . '/index.php')) {
73+
// Force trailing slashes on locale roots.
74+
if ($uri === '/' . $locale) {
75+
header('Location: ' . $uri . '/');
76+
die;
77+
}
78+
79+
$indexPath = $localeIndexPath;
80+
$scriptName = '/' . $locale . '/index.php';
7581
}
76-
77-
$indexPath = $sitePathPrefix . '/' . $locale . '/index.php';
78-
$scriptName = '/' . $locale . '/index.php';
7982
}
8083

8184
$_SERVER['SCRIPT_NAME'] = $scriptName;

0 commit comments

Comments
 (0)