M
M
Maxim Timofeev2014-12-04 15:44:19
Yii
Maxim Timofeev, 2014-12-04 15:44:19

How to configure urlmanager in yii2 to pass a non-digit parameter?

in Url manager

'urlManager' => [
            'enablePrettyUrl' => true,
            'enableStrictParsing' => false,
            'showScriptName' => false,
            'rules' => [
                'POST <controller:\w+>s' => '<controller>/create',
                '<controller:\w+>s' => '<controller>/index',
                'PUT <controller:\w+>/<id:\d+>'    => '<controller>/update',
                'DELETE <controller:\w+>/<id:\d+>' => '<controller>/delete',
                '<controller:\w+>/<id:\d+>'        => '<controller>/view'
                ]
        ],

DOMEN/index.php/products/1 works
DOMEN/index.php/products/cat1 gives error Unable to resolve the request: products/cat1
How to pass non-digit parameter? What is the feature?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Max, 2014-12-04
@webinar

'PUT <controller:\w+>/<id:\d+>'    => '<controller>/update',
                'DELETE <controller:\w+>/<id:\d+>' => '<controller>/delete',
                '<controller:\w+>/<id:\d+>'        => '<controller>/view'
                ]
        ],

d+ are only numbers

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question