1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-05 00:20:08 +01:00

Handle localized sites within a public directory

This commit is contained in:
Jason Varga
2017-08-08 15:06:41 -04:00
parent e91b844a8f
commit db5f5d80e9

View File

@@ -62,22 +62,24 @@ public function frontControllerPath($sitePath, $siteName, $uri)
$indexPath = $sitePath.'/index.php';
}
if ($this->isActualFile($sitePath.'/public/index.php')) {
if ($isAboveWebroot = $this->isActualFile($sitePath.'/public/index.php')) {
$indexPath = $sitePath.'/public/index.php';
}
$sitePathPrefix = ($isAboveWebroot) ? $sitePath.'/public' : $sitePath;
if ($locale = $this->getUriLocale($uri)) {
// Force trailing slashes on locale roots.
if ($uri === '/' . $locale) {
header('Location: ' . $uri . '/'); die;
}
$indexPath = $sitePath . '/' . $locale . '/index.php';
$indexPath = $sitePathPrefix . '/' . $locale . '/index.php';
$scriptName = '/' . $locale . '/index.php';
}
$_SERVER['SCRIPT_NAME'] = $scriptName;
$_SERVER['SCRIPT_FILENAME'] = $sitePath . $scriptName;
$_SERVER['SCRIPT_FILENAME'] = $sitePathPrefix . $scriptName;
return $indexPath;
}