1

I have following configuration in my web.php

    'urlManager' => [
        'enablePrettyUrl' => true,
        'showScriptName' => false,
        'enableStrictParsing' => false,
        'rules' => [
            'r/<url:\d+>' => 'r/index',
            [
                'pattern' => '<action>', 
                'route' => 'controller/<action>'
            ]
        ]            
    ]

When I type http://www.example.com/r/BRb2T5wCCz it shows 404. However, it should show me r/index page. What am I doing worng?

3
  • 1
    \d+ means digits only and you have got letters there as well. Commented Jan 18, 2017 at 11:12
  • Ok, it shoud be \s+ then? Commented Jan 18, 2017 at 11:20
  • Never mind. It seems it should be \w+ Commented Jan 18, 2017 at 11:31

1 Answer 1

1

As Bizley commented:

[The escape sequence] \d+ means digits only and you have got letters there as well.

You shouldn't use an escape sequence if you don't need to:

r/<url> => 'r/index',

You should go with \w+ only if your parameter will only contain letters, digits or underscores.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.