mirror of
https://github.com/getgrav/grav.git
synced 2026-03-04 11:31:43 +01:00
Improve support for regex redirects with query and params #1983
This commit is contained in:
@@ -2,9 +2,10 @@
|
||||
## 04/12/2018
|
||||
|
||||
1. [](#new)
|
||||
* added a new `Medium:thumbnailExists()` function [#1966](https://github.com/getgrav/grav/issues/1966)
|
||||
* Added a new `Medium:thumbnailExists()` function [#1966](https://github.com/getgrav/grav/issues/1966)
|
||||
1. [](#bugfix)
|
||||
* fixed an issue with `custom_base_url` always causing 404 errors
|
||||
* Fixed an issue with `custom_base_url` always causing 404 errors
|
||||
* Improve support for regex redirects with query and params [#1983](https://github.com/getgrav/grav/issues/1983)
|
||||
|
||||
# v1.4.3
|
||||
## 04/12/2018
|
||||
|
||||
@@ -469,14 +469,13 @@ class Pages
|
||||
if ($site_route) {
|
||||
$page = $this->dispatch($site_route, $all);
|
||||
} else {
|
||||
// Try Regex style redirects
|
||||
$uri = $this->grav['uri'];
|
||||
$source_url = $route;
|
||||
$extension = $uri->extension();
|
||||
if (isset($extension) && !Utils::endsWith($uri->url(), $extension)) {
|
||||
$source_url.= '.' . $extension;
|
||||
}
|
||||
|
||||
/** @var Uri $uri */
|
||||
$uri = $this->grav['uri'];
|
||||
/** @var \Grav\Framework\Uri\Uri $source_url */
|
||||
$source_url = $uri->uri(false);
|
||||
|
||||
// Try Regex style redirects
|
||||
$site_redirects = $config->get("site.redirects");
|
||||
if (is_array($site_redirects)) {
|
||||
foreach ((array)$site_redirects as $pattern => $replace) {
|
||||
|
||||
@@ -470,6 +470,23 @@ class Uri
|
||||
return $this->basename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the full uri
|
||||
*
|
||||
* @param bool $include_root
|
||||
* @return mixed
|
||||
*/
|
||||
public function uri($include_root = true)
|
||||
{
|
||||
if ($include_root) {
|
||||
return $this->uri;
|
||||
} else {
|
||||
$uri = str_replace($this->root_path, '', $this->uri);
|
||||
return $uri;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the base of the URI
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user