Exemplo n.º 1
0
 /**
  * @DynamicRoute /{string}
  * @param $shortUrl
  * @throws Error
  */
 function dynamicRouteTest($shortUrl)
 {
     $bean = Url::findUrl($shortUrl);
     if (!$bean) {
         throw new Error('The request URL is not exists', 404);
     } else {
         header('Location: ' . $bean->url);
     }
 }
Exemplo n.º 2
0
 public function redirect()
 {
     $requestPath = Request::getRequestPath();
     $requestPath = ltrim($requestPath, '/');
     $bean = Url::findUrl($requestPath);
     if (!$bean) {
         throw new Error('The request URL is not exists', 404);
     } else {
         header('Location: ' . $bean->url);
     }
 }