Skip to content

Commit

Permalink
Merge pull request #175 from zrayev/master
Browse files Browse the repository at this point in the history
Configurable language redirect
  • Loading branch information
mikehaertl authored May 4, 2022
2 parents 6f0f018 + ffd0fcb commit a3e74a7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion UrlManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ class UrlManager extends BaseUrlManager
*/
public $geoIpLanguageCountries = [];

/**
* @var int the HTTP status code.
* Defaults is 302.
*/
public $languageRedirectCode = 302;

/**
* @var \yii\web\Request
*/
Expand Down Expand Up @@ -625,7 +631,7 @@ protected function redirectToLanguage($language)
return;
}
Yii::trace("Redirecting to $url.", __METHOD__);
Yii::$app->getResponse()->redirect($url);
Yii::$app->getResponse()->redirect($url, $this->languageRedirectCode);
if (YII2_LOCALEURLS_TEST) {
// Response::redirect($url) above will call `Url::to()` internally.
// So to really test for the same final redirect URL here, we need
Expand Down

0 comments on commit a3e74a7

Please sign in to comment.