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!";

	DIE();


}



If I try to access the URL www.website.com/person/add-nationality/1 the controller is not found. Only if I change the action name to actionAddnationality and try to access www.website.com/person/addnationality/1 - removing the hyphen - will the controller be found.

Is there a workaround for this?

Thanks.


\w

doesn’t include “-”.

Try this instead:




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



That worked perfectly! Thanks!