需求:localhost/index.php/api/users/5=>localhost/api/users/5
1.开启Apache2重写模块
a2enmod rewrite
2.配置项目protected/config/main.php
增加‘showScriptName’=false
3.修改apache配置文件
AllowOverride None 修改成 AllowOverride All
4.在与入口文件目录增加.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
5.重启apache2
6.完毕