if ($_SERVER['REQUEST_URI']=='/path/to/page') {
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://site/path/to/page'");
exit();
}
if ($_SERVER['REQUEST_URI']=='/path/to/page') {
Yii::$app->response->redirect('/path/to/page', 301)->send();
Yii::$app->end();
return;
}