action with hyphen

what would be the controller and function name to get a url looking like my-controller/my-action ?

Well, i think you should create a route to map this kind of id into mycontroller/myaction

No, he want it with hyhpen. He can't create neither class nor method with dash in it. You can use CUrlManager to achieve this.

Alternative way is to attach handler to the onbeginRequest ( and preprocess the route removing hyphens. If you do so, then Built-in CApplication mechanism will dispatch it to mycontroller/myaction

How about using .htaccess rewriting rule?

propose one :)


Can you please provide an example on how to do that alternative way of yours to solve this? And what about if there isn’t a controller specified on the URL (e.g.

How about this approach:








I know this is a pretty old thread, but it was one of the first I found on google, so I will post my answer here.

I made a simple extension to the CUrlManager class.


'urlManager' => array(

	'class' => 'QUrlManager',





class QUrlManager extends CUrlManager


	public function parseUrl($request)


		// get uri

		$uri = parent::parseUrl($request);

		// remove hyphens

		return str_replace('-', '', $uri);



Hopes this helps someone!

Support for action name with dash is not currently supported by Yii:-(

Check out this workaround: