Improve support for regex redirects with query and params #1983

This commit is contained in:
Andy Miller
2018-04-18 15:02:53 -06:00
parent a49f3d460e
commit 3091a14223
3 changed files with 26 additions and 9 deletions

View File

@@ -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

View File

@@ -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) {

View File

@@ -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
*