예제 #1
0
파일: Index.php 프로젝트: sendya/shortUrl
 /**
  * @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);
     }
 }
예제 #2
0
파일: Short.php 프로젝트: sendya/shortUrl
 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);
     }
 }