diff --git a/src/Fast404.php b/src/Fast404.php index 66626a4..d3bbd2c 100644 --- a/src/Fast404.php +++ b/src/Fast404.php @@ -195,6 +195,23 @@ class Fast404 { return; } + // Check the URL alias table for the path after removing the last part. This + // to prevent subpathauto paths from returning a 404 response. + if (Settings::get('fast404_path_check_subpathauto', FALSE) && \Drupal::moduleHandler()->moduleExists('subpathauto')) { + // Check for a revision path. + $path_revision = preg_replace('/\/revisions\/(\d+)\/([a-zA-Z0-9]+)(?:\/([a-zA-Z0-9]+))?/', '', $path_noslash);; + $result = Database::getConnection()->query($sql, [':alias' => $path_revision])->fetchField(); + if ($result) { + return; + } + // Remove the last part from the URL to support content operations. + $path_noslash = substr($path_noslash, 0, strrpos($path_noslash, '/')); + $result = Database::getConnection()->query($sql, [':alias' => $path_noslash])->fetchField(); + if ($result) { + return; + } + } + // Check for redirects if set to respect them. if (Settings::get('fast404_respect_redirect', FALSE)) { $path_noslash = trim(urldecode($path), '/');