Answer the question
In order to leave comments, you need to log in
Yii2: how to make a 301 redirect on a website without .htaccess?
Good afternoon!
For some reason, .htaccess is disabled on the site, how to make a 301 redirect from one page to another, in yii2?
Answer the question
In order to leave comments, you need to log in
If anyone is interested, I solved it like this:
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;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question