Skip to content

Commit d384f11

Browse files
committed
Do not use prefix for default language.
If language restoring and showing default language are disabled we don't need in prefix for default language.
1 parent cfdb9b6 commit d384f11

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

UrlManager.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public function init()
138138
}
139139
}
140140
$this->_defaultLanguage = Yii::$app->language;
141-
return parent::init();
141+
parent::init();
142142
}
143143

144144
/**
@@ -201,6 +201,15 @@ public function createUrl($params)
201201
$languageRequired = false;
202202
}
203203

204+
// Do not use prefix for default language to prevent unnecessary redirect
205+
if ($languageRequired
206+
&& $language === $this->getDefaultLanguage()
207+
&& !$this->enableDefaultLanguageUrlCode
208+
&& !$this->enableLanguagePersistence
209+
) {
210+
$languageRequired = false;
211+
}
212+
204213
$url = parent::createUrl($params);
205214

206215
// Unless a language was explicitely specified in the parameters we can return a URL without any prefix

0 commit comments

Comments
 (0)