Skip to content

Commit db5f5d8

Browse files
committed
Handle localized sites within a public directory
1 parent e91b844 commit db5f5d8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

cli/drivers/StatamicValetDriver.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,24 @@ public function frontControllerPath($sitePath, $siteName, $uri)
6262
$indexPath = $sitePath.'/index.php';
6363
}
6464

65-
if ($this->isActualFile($sitePath.'/public/index.php')) {
65+
if ($isAboveWebroot = $this->isActualFile($sitePath.'/public/index.php')) {
6666
$indexPath = $sitePath.'/public/index.php';
6767
}
6868

69+
$sitePathPrefix = ($isAboveWebroot) ? $sitePath.'/public' : $sitePath;
70+
6971
if ($locale = $this->getUriLocale($uri)) {
7072
// Force trailing slashes on locale roots.
7173
if ($uri === '/' . $locale) {
7274
header('Location: ' . $uri . '/'); die;
7375
}
7476

75-
$indexPath = $sitePath . '/' . $locale . '/index.php';
77+
$indexPath = $sitePathPrefix . '/' . $locale . '/index.php';
7678
$scriptName = '/' . $locale . '/index.php';
7779
}
7880

7981
$_SERVER['SCRIPT_NAME'] = $scriptName;
80-
$_SERVER['SCRIPT_FILENAME'] = $sitePath . $scriptName;
82+
$_SERVER['SCRIPT_FILENAME'] = $sitePathPrefix . $scriptName;
8183

8284
return $indexPath;
8385
}

0 commit comments

Comments
 (0)