/** * Runs the action * * @return string result content */ public function run($slug) { if ($link = Link::findOne(['slug' => $slug])) { $statusCode = empty($link->status_code) ? $this->defaultStatusCode : $link->status_code; return Yii::$app->getResponse()->redirect($link->url, $statusCode); } else { throw new \yii\web\NotFoundHttpException('Page not found.'); } }