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!



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);        	



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