M
M
Maxim Lagoysky2017-04-17 13:45:13
Yii
Maxim Lagoysky, 2017-04-17 13:45:13

Creating rules in urlManager in Yii2?

Let's say there is such a link,
" http://mysite.com/site/sub?al=villas-and-houses "
I want to see " http://mysite.com/villas-and-houses " when I go to it,
wrote this rule, but there is one but, it works where there is one word in the get parameter or is separated by an underscore, and where there is a hyphen it does not want to work, how can I make it work with a hyphen?
'' => 'site/sub',

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2017-04-17
@lagoy

'urlManager' => [
            'class' => 'yii\web\UrlManager',
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                '<al>' => 'site/sub'
            ]
        ],

M
Mi7teR, 2017-04-17
@Mi7teR

add after all rules
'<al:[\w-]+>' => 'site/sub'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question