Answer the question
In order to leave comments, you need to log in
How to remove slash using Yii1?
return [
...
'on beforeRequest' => function () {
$pathInfo = Yii::$app->request->pathInfo;
$query = Yii::$app->request->queryString;
if (!empty($pathInfo) && substr($pathInfo, -1) === '/') {
$url = '/' . substr($pathInfo, 0, -1);
if ($query) {
$url .= '?' . $query;
}
Yii::$app->response->redirect($url, 301);
Yii::$app->end();
}
},
...
];
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question