如何在yii框架中自动设置url友好

nig*_*2k1 7 php frameworks yii

我只是学习yii框架并阅读本教程关于yii如何设置url

但我不知道,假设我有10个控制器,我应该在配置文件中逐个定义控制器吗?是否有更好的方法来设置所有控制器的www.yoursite.com/yourController/yourAction/yourID网址友好?

我认为codeigniter自动做到了...... yii怎么样?

Chr*_*ris 19

在/protected/config/main.php中添加..

    'urlManager'=>array(
        'urlFormat'=>'path',
        'showScriptName' => false,      
        ),
    ),
Run Code Online (Sandbox Code Playgroud)

在您的Web根目录中.htaccess ..

Options +FollowSymLinks
IndexIgnore */*
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
Run Code Online (Sandbox Code Playgroud)