How to access static php files under the yii framework without having to create multiple actions, here is a simple record, I hope to leading to a better implementation:
1, configured in main.php
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'rules'=>array(
'post/<view:.*>.html'=>'post/page/',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
‘post/.html’=>’post/page/’ This line of code is the most important
2, implement a postController
<?php
class PostController extends Controller{
public function actions() {
return array (
'page' => array (
'class' => 'CViewAction'
)
);
}
}
3, add the post/pages directory in the corresponding views directory, and then add a static php file (such as 12345.php) in the pages directory
It can be accessed via http://domainname/post/12345.html. If there is a subdirectory (such as 20120920/123456.php), you can pass