Sfoglia il codice sorgente

Redirection des urls avec un slash à la fin

refactoring
parent
commit
47d2fd234f
1 ha cambiato i file con 10 aggiunte e 0 eliminazioni
  1. +10
    -0
      common/config/main.php

+ 10
- 0
common/config/main.php Vedi File

@@ -40,6 +40,16 @@ $serverName = $_SERVER['SERVER_NAME'] ;

return [
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
'on beforeRequest' => function () {
$app = Yii::$app;
$pathInfo = $app->request->pathInfo;
if (!empty($pathInfo) && substr($pathInfo, -1) == '/') {
$url = Yii::$app->request->getAbsoluteUrl();
$url = substr($url, 0, strlen($url) - 1);
Yii::$app->getResponse()->redirect($url, 301);
Yii::$app->end();
}
},
'components' => [
'user' => [
'class' => 'yii\web\User',

Loading…
Annulla
Salva