diff --git a/wire/core/PagesRequest.php b/wire/core/PagesRequest.php index 04bbdd21..42b8f327 100644 --- a/wire/core/PagesRequest.php +++ b/wire/core/PagesRequest.php @@ -11,7 +11,7 @@ * ~~~~~ * #pw-body * - * ProcessWire 3.x, Copyright 2022 by Ryan Cramer + * ProcessWire 3.x, Copyright 2023 by Ryan Cramer * https://processwire.com * * @method Page|NullPage getPage() @@ -301,15 +301,16 @@ class PagesRequest extends Wire { // populate request path to class as other methods will now use it $this->setRequestPath($path); - - // determine if index.php is referenced in URL - if(stripos($this->dirtyUrl, 'index.php') !== false && stripos($path, 'index.php') === false) { + + // determine if original URL had anything filtered out of path that will suggest a redirect + list($dirtyUrl,) = explode('?', "$this->dirtyUrl?", 2); // exclude query string + if(stripos($dirtyUrl, 'index.php') !== false && stripos($path, 'index.php') === false) { // force pathFinder to detect a redirect condition without index.php - $path = rtrim($path, '/') . '/index.php'; - } else if(strpos($this->dirtyUrl, '//') !== false) { + $dirtyUrl = strtolower(rtrim($dirtyUrl, '/')); + if(substr("/$dirtyUrl", -10) === '/index.php') $path = rtrim($path, '/') . '/index.php'; + } else if(strpos($dirtyUrl, '//') !== false) { // force pathFinder to detect redirect sans double slashes, /page/path// => /page/path/ - list($dirtyUrl,) = explode('?', "$this->dirtyUrl?", 2); // exclude query string - if(strpos($dirtyUrl, '//') !== false) $path = rtrim($path, '/') . '//'; + $path = rtrim($path, '/') . '//'; } // get info about requested path