Yii framwork - Url Manager

Url Manager

A. User-friendly URLS
array(
    ......
    'components'=>array(
        ......
        'urlManager'=>array(
            'urlFormat'=>'path',
            'showScriptName'=> false,
            'urlFormat'=> false,
            'rules'=>array(
                '<controller:\w+>/<id:\d+>'=>'<controller>/view ',
                '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
                '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
            ),
        ),
    ),
);
 
B. Set .htaccess
 
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php

posted on 2012-10-15 17:04  技术员  阅读(247)  评论(0)    收藏  举报

导航