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

Redirect wp-admin to wp-admin/ (#96)

When attempting to access `wp-admin` unauthenticated, WordPress redirects to `wp-admin` instead of `wp-admin/` which causes issues with all the links in the admin until you add the trailing slash.
This commit is contained in:
Thiery Laverdure
2016-07-15 11:44:49 -04:00
committed by Taylor Otwell
parent 68ff17aa59
commit 60dc951513

View File

@@ -28,6 +28,23 @@ public function frontControllerPath($sitePath, $siteName, $uri)
$_SERVER['PHP_SELF'] = $uri;
$_SERVER['SERVER_ADDR'] = '127.0.0.1';
return parent::frontControllerPath($sitePath, $siteName, $uri);
return parent::frontControllerPath(
$sitePath, $siteName, $this->forceTrailingSlash($uri)
);
}
/**
* Redirect to uri with trailing slash.
*
* @param string $uri
* @return string
*/
private function forceTrailingSlash($uri)
{
if (substr($uri, -1 * strlen('/wp-admin')) == '/wp-admin') {
header('Location: '.$uri.'/'); die;
}
return $uri;
}
}