1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-10 00:37:02 +02:00

Update so that requests containing a double slash at the end of the path get redirected to the single slash (or no-slash) version

This commit is contained in:
Ryan Cramer
2023-02-02 14:21:53 -05:00
parent dd93de3f91
commit 22250b483f

View File

@@ -304,8 +304,12 @@ class PagesRequest extends Wire {
// determine if index.php is referenced in URL
if(stripos($this->dirtyUrl, 'index.php') !== false && stripos($path, 'index.php') === false) {
// this will force pathFinder to detect a redirect condition
// force pathFinder to detect a redirect condition without index.php
$path = rtrim($path, '/') . '/index.php';
} else if(strpos($this->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, '/') . '//';
}
// get info about requested path