Answer the question
In order to leave comments, you need to log in
Why does the slash appear as %2F?
Faced the following problem. For example, I have a page like yii.loc:8080/about/contacts and I want a trailing slash to be automatically added to such pages. I do not consider the option of adding a rule to the server configuration, because it should be possible to add or remove a slash from under the admin panel. I used UrlNormalizer in settings
return [
'class'=>'common\components\lang\LangUrlManager',
'enablePrettyUrl'=>true,
'showScriptName'=>false,
'suffix' => '/',
'normalizer' => [
'class' => 'yii\web\UrlNormalizer',
'action' => yii\web\UrlNormalizer::ACTION_REDIRECT_TEMPORARY, // use temporary redirection instead of permanent
],
'rules'=> [
// Pages
['pattern'=>'<url:[\w_\/-]+>', 'route'=>'page/view'],
]
];
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question