Browse Source

Redirection des urls avec un slash à la fin

refactoring
Guillaume Bourgeois 5 years ago
parent
commit
4e886af251
1 changed files with 1 additions and 1 deletions
  1. +1
    -1
      common/config/main.php

+ 1
- 1
common/config/main.php View File

@@ -43,7 +43,7 @@ return [
'on beforeRequest' => function () {
if(method_exists(Yii::$app->request, 'getAbsoluteUrl')) {
$url = Yii::$app->request->getAbsoluteUrl();
if (!empty($url) && substr($url, -1) == '/' && substr($url, -5) != '.net/') {
if ($_SERVER['SERVER_NAME'] != 'localhost' && !empty($url) && substr($url, -1) == '/' && substr($url, -5) != '.net/') {
$url = substr($url, 0, strlen($url) - 1);
Yii::$app->getResponse()->redirect($url, 301);
Yii::$app->end();

Loading…
Cancel
Save