diff --git a/code/services/MisdirectionService.php b/code/services/MisdirectionService.php index a07ae92..f8d35f6 100644 --- a/code/services/MisdirectionService.php +++ b/code/services/MisdirectionService.php @@ -76,8 +76,8 @@ public function getMapping($URL, $host = null) { // Enforce any hostname restriction that may have been defined. - if(is_null($host) && Controller::curr()) { - $host = Controller::curr()->getRequest()->getHeader('Host'); + if(is_null($host) && ($controller = Controller::curr())) { + $host = $controller->getRequest()->getHeader('Host'); } $matches = $matches->where("(HostnameRestriction IS NULL) OR (HostnameRestriction = '" . Convert::raw2sql($host) . "')"); $regex = clone $matches;