Config Main urlManager

Hi there,

I have a problem with my config/main.php management, that is I want my Yii site to be able to grab any “leftover” actions to be a certain action’s GET parameter.

The following is the example of config/main.php urlManager:

‘about’=>‘site/about’, // www.mydomain.com/about => Go to actionAbout in SiteController

‘contact’=>‘site/contact’, // www.mydomain.com/contact => Go to actionContact in SiteController

‘whatshouldiputhere’=>'site/dothings?param=whatshouldiputhere

The last line handles the URL so that:

mydomain.com/about1 => Go to actionDoThings in SiteController with $_GET[‘param’]=about1

mydomain.com/qwertyuiop => Go to actionDoThings in SiteController with $_GET[‘param’]=qwertyuiop

mydomain.com/a/b/c/d/e/f => Go to actionDoThings in SiteController with $_GET[‘param’]=a/b/c/d/e/f

mydomain.com/a?safety=isitprotected => Go to actionDoThings in SiteController with $_GET[‘param’]=a?safety=isitprotected, which then goes to a certain 404 redirect in actionDoThings

How can I achieve this?

Please help

Regards,

Ron

This should do it, didn’t tried it though.




'about'=>'site/about', 

'contact'=>'site/contact', 

'*/<:param>'=>'site/dothings',//always last line, catch all rule.



Thanks for the quick response, twisted1919

I have tried yours, but I have got this error:

The URL pattern "*/<:param>" for route "site/dothings" is not a valid regular expression.

Correct, i tried too:)

Here is what it’s working as you want:




'<param:.*>'=>'site/dothings',



Be sure that it is the last line.

Romanian Yii expert is spotted in this thread! =D

Thanks a lot!! vote +1 =)

Thx, glad i could help:)