Issue with URL pattern matching hyphenated URLs

Bit of a curious problem this one, and I can’t seem to resolve it.

Currently using this as the only URL rule: -

'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>'

In my Person controller, I have the following action: -

public function actionAddNationality($id){

	echo "controller found!";



If I try to access the URL the controller is not found. Only if I change the action name to actionAddnationality and try to access - removing the hyphen - will the controller be found.

Is there a workaround for this?



doesn’t include “-”.

Try this instead:

'<controller:\w+>/<action:[\w-]+>/<id:\d+>' => '<controller>/<action>'

That worked perfectly! Thanks!