T
T
tobik-872016-02-25 14:20:45
Yii
tobik-87, 2016-02-25 14:20:45

How to make normal links?

Good afternoon.
In the settings I wrote:

'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
     'news/<id:\d+>/<url:\d+>'=>'news/view', 
               ]
]

I'm making a link:
<?= Html::a('Название', ['view', 'id' => '3', 'url' => 'statya']) ?>

Now the link is generated like this:
/news/view?id=8&url=statya
And you need to do it
/news/3/statya
with only one number: (
/news/3
How to do it? How to remove ?, &, id and url ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Klyuev, 2016-02-25
@tobik-87

'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
     'news/<id:\d+>/<url:\w+>'=>'news/view', 
               ]
]

- d - means number
- w - string

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question