Esempio n. 1
0
 function match(IHttpRequest $httpRequest)
 {
     $path = $httpRequest->getUrl()->getPath();
     //look for redirect record
     $newurl = RedirectModel::getByOldUrl($path);
     //fix pathinfo bug - strip "/index.php/" from url
     if (!$newurl and preg_match('~^/index\\.php~', $path)) {
         $newurl = preg_replace('~^/index\\.php~', '', $path);
     }
     if ($newurl) {
         RedirectModel::hit($path);
         if ($p = RedirectModel::parseHashIdLang($newurl)) {
             $newurl = Environment::getLinkHelper()->pageLink($p[0], $p[1]);
             if ($newurl == NULL) {
                 return NULL;
             }
         }
         header("Location: {$newurl}", true, 301);
         //TODO (ask) if comented, output twice :/ better?
         echo "Moved permanetly to <a href='{$newurl}'>{$newurl}</a>";
         exit;
     }
     return NULL;
 }