mirror of
https://github.com/getgrav/grav.git
synced 2026-02-22 14:38:13 +01:00
Support for redirects not just routes
This commit is contained in:
@@ -236,11 +236,19 @@ class Pages
|
||||
// Fetch page if there's a defined route to it.
|
||||
$page = isset($this->routes[$url]) ? $this->get($this->routes[$url]) : null;
|
||||
|
||||
// If the page cannot be reached, look into site wide routes + wildcards
|
||||
|
||||
|
||||
// If the page cannot be reached, look into site wide redirects, routes + wildcards
|
||||
if (!$all && (!$page || !$page->routable())) {
|
||||
/** @var Config $config */
|
||||
$config = $this->grav['config'];
|
||||
|
||||
// Try redirects
|
||||
$redirect = $config->get("site.redirects.{$url}");
|
||||
if ($redirect) {
|
||||
$this->grav->redirect($redirect);
|
||||
}
|
||||
|
||||
// See if route matches one in the site configuration
|
||||
$route = $config->get("site.routes.{$url}");
|
||||
if ($route) {
|
||||
|
||||
Reference in New Issue
Block a user