/** * @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); } }
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); } }