1、首先需要开启apache的mod_rewrite模块:去掉LoadModule rewrite_module modules/mod_rewrite.so前的“#”符号,并有“AllowOverride All”;
2、去掉注释:
1 2 3 4 5 6 7 8 | '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>', ), ), |
3、在与index.php文件同级目录下添加文件“.htaccess”,内容如下:
1 2 3 4 5 6 7 | 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 |



