How To Replace Url “ ” By “-” Or “_”?

How can I achive this using URL MANAGER ?

I hope someone can give me some insight or guidance to helpme resolve this issue. Thank you in advance for your time.

That’s how urlencode() works.

You can extend CUrlManager and override createPathInfo (and I think parsePathInfo should also be modified)

Thank you for your hint.

I’ve successfully extented the CUrlManager!


		'urlManager'=>array(

			'class'=>'application.components.UrlManager',






class UrlManager extends CUrlManager

{

    public function createUrl($route,$params=array(),$ampersand='&')

    {

        if (isset($params['title']) && !empty($params['title'])){

        	$str = $params['title'];

        	$str =  preg_replace("![^a-z0-9]+!i", "_", $str);        	

        	$params['title']=$str;

        }

        return parent::createUrl($route, $params, $ampersand);

    }

}