/**
* Parses the given request and returns the corresponding route and parameters.
* @param UrlManager $manager the URL manager
* @param Request $request the request component
* @return array|boolean the parsing result. The route and the parameters are returned as an array.
* If false, it means this rule cannot be used to parse this path info.
*/
public function parseRequest($manager, $request)
{
foreach ($this->skip as $item) {
if (strpos($request->getPathInfo(), $item) !== false) {
return false;
}
}
$path = $request->getPathInfo();
$redirect = false;
// Слэш в конце
if (substr($path, -1) == '/') {
$redirect = true;
$path = trim($path, '/');
}
// Двойной слэш
if (strpos($path, '//') !== false) {
$redirect = true;
$path = str_replace('//', '/', $path);
}
// Символы в верхнем регистре
if (($tmpUrl = strtolower($path)) !== $path) {
$redirect = true;
$path = $tmpUrl;
}
if ($redirect) {
Yii::$app->response->redirect([$path], 301);
Yii::$app->end();
}
return false;
}