官方默认的.htaccess文件
<IFModule mod_rewrite.c>
Options+FollowSymlink-Multiviews
RewriteEngine On
RewirteCond %{REQUEST_FILENAME} !-d
RewirteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$index.php/$1[QSA,PT,L]
</IFModule>
如果用的phpstudy,规则如下:
<IFModule mod_rewrite.c>
Options+FollowSymlink-Multiviews
RewriteEngine On
RewirteCond %{REQUEST_FILENAME} !-d
RewirteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$index.php[L,E=PATH_INFO:$1]
</IFModule>
如果是Nginx环境的话,可以在Nginx.conf中添加:
location / {
if(!-e $request_filename){
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}