环境是win10的phpstudy最新版也就是v8.0
访问http://blog_test.com:801/index/article/index.html 域名/入口文件/模块/控制器/操作/[参数名/参数值…],这个需要nginx环境支持pathinfo,Apache默认支持,Nginx不支持,需要手动配置。
配置本地域名步骤省略…
1.首先打开phpstudy小皮面板
2.打开设置 点击vhosts.conf 再点击 ‘你配置好的域名’
百度教程都是修改nignx.conf文件这边为什么修改vhosts.conf呢,是因为nignx.conf里面也是引入vhosts.conf的配置
3.加入以下代码
location / {
index index.html index.htm;
#autoindex on;
# 添加下面代码 开启nginx的重写模块
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
# 添加代码截止
}
4.如果下面代码没有再添加 (我的小皮原来是有的这里跳过)
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#添加下面两句 fastcgi权限,可以支持 ?s=/module/controller/action的url访问模式
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#添加下面两句 支持 index.php/index/index/index的pathinfo模式
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
# 添加代码截止
include fastcgi_params;
}