1、确保Apache配置文件httpd.conf的 mod_rewrite.so 模块开启。方法:去掉前面的 “#”
2、在项目入口文件的同级目录下(即index.php所在目录),新建 .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
3、重启Apache,原来的访问地址
http://domainName/index.php/user/login
就可简化为
http://domainName/user/login