URL Routing - unable to match specific GET param?

When creating rules for a route, it appears there is no way to say that:




array('label'=>'About', 'url'=>array('/site/page', 'view'=>'about')),



should be matched exactly.

I can write rules for /site/page with no problem, but capturing the fact that "view" value must equal "about" appears to not be possible?

The only alternative I’ve found is to write a full path URL, such as:




array('label'=>'About', 'url'=>'/site/page/view/about'),



Which would then be matched by:




'<_v:\w+>'=>'site/page/view/<_v>',



But strangely enough, is not matched by:




'<view:\w+>'=>'site/page',



This means that, a full hard-coded path route can be matched by regex expecting a hard-coded path.

But you can’t match a parameterized route using a path format.

And you can’t match a path format route using a parameterized format.

And you can’t match an explicit parameterized route with a specific value.

Correct?

I tend to be unclear, if that is the case here, let me know…

A little. ;)

So you have a rule with parameters. If one of these parameters has a specific value, another rule should match, right? You can try this:


array(

  'some/other/url/<view:about>'=>'site/page',

  '<view:\w+>'=>'site/page',

)

Thanks Mike, I appear to have missed that.

What about if you want an empty route? (i.e. - site index should match /site/page/view/whatever)

In that situation, there doesn’t seem to be any way to match, without having the result show up in the route, correct?

Again not sure if i understand. You mean something like this?


array(

  'some/page/view/whatever'=>'site/index',

)

Something like this:




array(

    ''=>'site/page/view/whatever',

)



So that the website’s index will map to “site/page/view/whatever”, and links to that file won’t mention the file path.

So it would always be:




http://www.mysite.com/



Instead of:




http://www.mysite.com/site/page/view/whatever



I’m confused now :)


array(

    ''=>'site/page/view/whatever',

)

The right side is not a route…

To clarify:




array(

    ''=>'site/page/view/whatever',

)



The above will match a URL created in Yii that matches that exact format. The URL itself is a Yii PATH-format URL, though when using the command to create a URL, Yii probably sees it as a complete URL instead of a route.

What I should have asked was, a Yii URL that creates:


site/page/view/whatever

Would look like this when passed to $this->createUrl():


array('site/page', array('view'=>'whatever'))

So how can I match that specifically as a route rule, so that it acts as the index page?

Currently I’ve had to resort to creating the URL in Yii using the PATH format, but to maintain consistency, I’d much rather use the route/params style.

I guess what I’m looking for is the ability to turn this:




array(

    ''=>'site/page/view/whatever',

)



into this:




array(

    ''=>array('site/page', 'params'=>array('view'=>'whatever')),

)



Maybe it’s easier if you supply a list of different arguments for creatUrl() and what URLs you’d like to be created. Actually i still don’t really understand what you try to do…

I’m not sure, but is this what you want?

Nice find Y!!, that would likely work. I’ll star that ticket so I’m notified when it’s solved, thanks!