Rewriting static pages

I was following the guide here: http://www.yiiframework.com/wiki/22/how-to-display-static-pages-in-yii/

I had a scenario where I had a URL very similar to this:


http://www.example.com/index.php?r=site/page&view=help.contact

Can I easily rewrite it to this?


http://www.example.com/help/contact

I have working rules for pages, but it still requires me to use the . for a subfolder, not a /


'<view:(program|program.parents|program.teachers|sponsor)>'=>'site/page',

You cant use / there, i think there is no workaround.

Thanks, glad I didn’t waste my time :)

It was my opinion, but everything is always posible, i mean you can extend CUrlManager and change the format for static pages subdirectories from ‘.’ to say ‘//’ and make other modifications to get your desired behavior.

What I mean is that you can do this, out of the box IMO.

You can do:


'program' => array('site/page', 'defaultParams' => array('view' => 'program')),

'program/parents' => array('site/page', 'defaultParams' => array('view' => 'program.parents')),

...



When viewing <domain>/program/parents I receive a 404 error: Unable to resolve the request "program/parents".




				'gii'=>'gii',

				'<controller:\w+>/<id:\d+>'=>'<controller>/view',

				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

				'program' => array('site/page', 'defaultParams' => array('view' => 'program')),

				'program/parents' => array('site/page', 'defaultParams' => array('view' => 'program.parents')),



Problems is <controller:\w+>/<action:\w+> matches the last rule. You should put such general rules on the bottom.




                                'gii'=>'gii',

                                'program' => array('site/page', 'defaultParams' => array('view' => 'program')),

                                'program/parents' => array('site/page', 'defaultParams' => array('view' => 'program.parents'))

                                '<controller:\w+>/<id:\d+>'=>'<controller>/view',

                                '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

                                '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',



Wow, sure enough. Thanks for your help, I wasn’t sure this was possible!

Final config:




				'gii'=>'gii',

				'program/parents' => array('site/page', 'defaultParams' => array('view' => 'program.parents')),

				'program/teachers' => array('site/page', 'defaultParams' => array('view' => 'program.teachers')),

				'program/hospitals' => array('site/page', 'defaultParams' => array('view' => 'program.hospitals')),

				'<view:(program|get|sponsor|gallery|news)>'=>'site/page',

				'<controller:\w+>/<id:\d+>'=>'<controller>/view',

				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',