yii中的404错误。网址不通

时间:2014-04-24 06:20:27

标签: .htaccess yii

我的网址

'urlManager'=>array(
                          'urlFormat'=>'path',
                          'showScriptName'=>false,
                          'rules'=>array(
                                            '<controller:\w+>/<id:\d+>'=>'<controller>/view',
                                           '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
                                          '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
                                         ),

我的htaccess

RewriteEngine  On
RewriteBase  /
RewriteCond   %{REQUEST_FILENAME} !-f
RewriteCond   %{REQUEST_FILENAME} !-d
RewriteRule    ^(.*)\?*$ index.php/$1 [L,QSA]

1 个答案:

答案 0 :(得分:1)

这对我有用。请试试这个

'urlManager'=>array(
    'urlFormat'=>'path',
        'rules'=>array(
            '<controller:\w+>/<id:\d+>'=>'<controller>/view',
            '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
            '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
        ),
        'showScriptName'=>false,
    ),

在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