1、Apache作为服务器的话
修改httpd.conf
打开
Apacha配置文件代码
LoadModule rewrite_module modules/mod_rewrite.so
查找并替换
Apach配置文件代码
AllowOverride none -> AllowOverride All
2、nginx作为服务器的话,在Nginx的配置文件中location段添加以下代码即可。
注:lnmp 一键安装包,这个配置文件路径一般是/usr/local/nginx/conf/vhost/域名.conf
保存后,执行 /usr/local/nginx/sbin/nginx -s reload 平滑重启 nginx 即可生效。
location ~ \.php$ {
# root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}