E
E
edik892016-12-09 13:43:04
Yii
edik89, 2016-12-09 13:43:04

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'],
    ]
];

Everything works, but the problem is that the page yii.loc:8080/about/contacts is converted to yii.loc:8080/about%2Fcontacts Why is the slash converted to %2 and how can I get rid of it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
edik89, 2016-12-09
@edik89

Decided by redefining UrlManager and regular expression

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question