diff --git a/core/lib/Drupal/Core/EventSubscriber/CustomPageExceptionHtmlSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/CustomPageExceptionHtmlSubscriber.php index 96bd6d8..0422bf0 100644 --- a/core/lib/Drupal/Core/EventSubscriber/CustomPageExceptionHtmlSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/CustomPageExceptionHtmlSubscriber.php @@ -63,7 +63,7 @@ protected static function getPriority() { */ public function on403(GetResponseForExceptionEvent $event) { $path = $this->aliasManager->getPathByAlias($this->configFactory->get('system.site')->get('page.403')); - $this->makeSubrequest($event, $event->getRequest()->getBaseUrl() . $path, Response::HTTP_FORBIDDEN); + $this->makeSubrequest($event, $event->getRequest()->getBasePath() . '/' . $path, Response::HTTP_FORBIDDEN); } /** @@ -71,7 +71,7 @@ public function on403(GetResponseForExceptionEvent $event) { */ public function on404(GetResponseForExceptionEvent $event) { $path = $this->aliasManager->getPathByAlias($this->configFactory->get('system.site')->get('page.404')); - $this->makeSubrequest($event, $event->getRequest()->getBaseUrl() . $path, Response::HTTP_NOT_FOUND); + $this->makeSubrequest($event, $event->getRequest()->getBasePath() . '/' . $path, Response::HTTP_NOT_FOUND); } } diff --git a/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionHtmlSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionHtmlSubscriber.php index 06073ea..d6782b2 100644 --- a/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionHtmlSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionHtmlSubscriber.php @@ -96,9 +96,9 @@ public function on404(GetResponseForExceptionEvent $event) { protected function makeSubrequest(GetResponseForExceptionEvent $event, $url, $status_code) { $request = $event->getRequest(); - $current_url = $request->getUri(); + $current_url = $request->getBasePath() . $request->getPathInfo(); - if ($url && $url != $current_url) { + if ($url != $request->getBasePath() . '/' && $url != $current_url) { if ($request->getMethod() === 'POST') { $sub_request = Request::create($url, 'POST', drupal_get_destination() + ['_exception_statuscode' => $status_code] + $request->request->all(), $request->cookies->all(), [], $request->server->all()); }