/** * @param SS_HTTPRequest $request * @throws SS_HTTPResponse_Exception */ public function onBeforeHTTPError404($request) { $url = strtolower($this->getUrl($request)); $oldPage = OldURLRedirect::get_from_url($url); // If there's a match, direct! if ($oldPage) { $response = new SS_HTTPResponse(); $dest = $oldPage->getRedirectionLink(); $response->redirect(Director::absoluteURL($dest), $oldPage->getRedirectCode()); throw new SS_HTTPResponse_Exception($response); } }