Spaces in URL/redirects?

I currently have the path of /user/name/(name) successfully redirecting to /user/view/profile?name=(name), with the rule “‘user/name/<name:\w+>’ => ‘user/view/profile’”. If I try user/name/DigitalMan, it redirects to the profile of DigitalMan, and the same goes for any other valid contiguous user name. The problem occurs with a user name that contains spaces. Something like “/user/name/Carnal Denizen” gives a 404, claiming ‘Unable to resolve the request “user/name/Carnal Denizen”.’ However, if I bypass the redirect rule and type in “/user/view/profile?name=Carnal Denizen”, it works perfectly. That indicates a problem with the rule. But, what is it?

Bump? I can’t be the only one who’s had this trouble…

… Anyone? Please?

Hello DigitalMan,

The first question that comes into my mind is that why aren’t you urlencoding the name? I’m not sure what your issues is but try urlencoding it and see if that helps.

Try changing from <name:\w+> to <name:[\w ]+>

Heeey, there we go! Took me a while to see that space in there. Switched it to ‘<name:[\w\s]+>’ for good measure. That was driving me nuts, thank you so much!

Hello, sorry for thread hijack for I thought creating similar thread with exact same problem is pointless so here is the problem i’m facing,

I started my experiment starting off the Blog example in demo directory, decided to enhance the URL rewrites, so far I have came up with following lines which does the job fine with some small issues



		'showScriptName' => false,










right now my links look like:

I want to make everything in title lowercase and get rid of + sign,

I tried what was posted above but it doesn’t work for me, I know with regular PHP I can create function do it that way but using the Yii framework everything is still foggy, I’ve never been a good manual reader either, I prefer trial and error which helps me learn and not forget so to be honest I haven’t gone through the documentation yet

Edit, ok now I understand my approach was wrong, I still need to write a function or perhaps extend the existing getUrl or createUrl methods so they create the urls to my desire, just like explained in

though I’m still having some hard time trying to figure out why my ActiveRecord.php component that I created following the example in the link above is not perhaps active?


figured what’s happening, for the records posting it here

Following the example on

I came up with


class ActiveRecord extends CActiveRecord


    public function getUrl()





        // add the title parameter to the URL

        if($this->hasAttribute('title')) {

            $this->title = preg_replace("`\[.*\]`U","",$this->title);

            $this->title = preg_replace('`&(amp;)?#?[a-z0-9]+;`i','-',$this->title);

	    $this->title = htmlentities($this->title, ENT_COMPAT, 'utf-8');

	    $this->title = preg_replace( "`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);`i","\\1", $this->title );

	    $this->title = preg_replace( array("`[^a-z0-9]`i","`[-]+`") , "-", $this->title);

            $this->title = strtolower(trim($this->title, '-'));



        return Yii::app()->urlManager->createUrl($controller.'/view', $params);






class Post extends CActiveRecord


class Post extends ActiveRecord

commented out following bit


	public function getUrl()


		return Yii::app()->createUrl('post/view', array(