Yii2 using hyphenated URLs in URL manager rules
When you’re playing around with URL rules and you get the dreaded 404 message, there isn’t very much help around.

I recently used an action with two words in camel case like actionTestThis which, in Yii2, translates to a url like ‘mycontroller/test-this’.

But if you’ve put in a special rule for this in your url manager, perhaps redirecting this to another controller

  'mycontroller/<action:w+>' => 'mycontroller2/<action>',

You will end with that lovely 404 message

What you need to put is

  'mycontroller/<action:w+(-w+)*>' => 'mycontroller2/<action>'

Let’s Start a Project!

Contact Me