public function checkRedirects()
    {
        // remove trailing slash and lowercase so there aren't multiple copies to cache
        $uri = strtolower(rtrim($this->Request->getAdjustedRequestURI(), '/'));
        $qs = $this->Request->getQueryString();

        if (($previousRedirect = $this->TemplateCache->get('redirect:' . $uri)) !== false) {
            $this->Logger->debug('Using cached redirect: ' . $uri . ' -> ' . $previousRedirect);

            if ($previousRedirect == 'null')
                return;

            // let's not let the browser cache these permanently
            $this->Response->addHeader('Cache-Control', 'max-age=' . $this->cachedRedirectTTL);
            $this->Response->addHeader('Expires', $this->DateFactory->newLocalDate('+' . $this->cachedRedirectTTL . ' seconds')->toRFCDate());

            $this->Response->sendStatus(Response::SC_MOVED_PERMANENTLY);
            $this->Response->sendRedirect($previousRedirect . (!empty($qs) ? '?' . $qs : ''));
            return;
        }

        $redirects = $this->redirectService->findAll();

        foreach ((array)$redirects as $test_uri => $new_url ) {
            $this->Logger->debug($test_uri);

            $m     = null;
            $re    = str_replace('/', '\/', $test_uri);
            $match = preg_match("/^". $re . "$/i", $uri, $m);

            if ($match) {
                if (!empty($new_url)) {
                    foreach ($m as $n => $v) {
                        $new_url = str_replace('$' . $n, $v, $new_url);
                    }
                }

                $this->TemplateCache->put('redirect:' . $uri, $new_url, $this->cachedRedirectTTL);

                // let's not let the browser cache these permanently
                $this->Response->addHeader('Cache-Control', 'max-age=' . $this->cachedRedirectTTL);
                $this->Response->addHeader('Expires', $this->DateFactory->newLocalDate('+' . $this->cachedRedirectTTL . ' seconds')->toRFCDate());

                $this->Response->sendStatus(Response::SC_MOVED_PERMANENTLY);
                $this->Response->sendRedirect($new_url . (!empty($qs) ? '?' . $qs : ''));
                return;
            }
        }

        $this->TemplateCache->put('redirect:' . $uri, 'null', $this->cachedRedirectTTL);
    }