ThinkPHP的URL访问

url访问

http://www.kancloud.cn/manual/thinkphp5/118012
ThinkPHP5.0在没有启用路由的情况下典型的URL访问规则是:
http://serverName/index.php(或者其它应用入口文件)/模块/控制器/操作/[参数名/参数值...]
注意:5.0取消了URL模式的概念,并且普通模式的URL访问不再支持,如果不支持PATHINFO的服务器可以使用兼容模式访问如下:
http://serverName/index.php(或者其它应用入口文件)?s=/模块/控制器/操作/[参数名/参数值...]

我想让支持/模块/控制器/操作
修改nginx配置

server {
        listen 80;
        server_name tp_web; #绑定域名
                index index.htm index.html index.php; #默认文件
                root /home/komiles/file/code/github/think-php/public; #网站根目录
        location ~ .php {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi_params;
        }
        include rewrite/tp.conf;
        if (!-f $request_filename){
                rewrite (.*) /index.php;
        }
        access_log /data/logs/access_tp_web.log;
        error_log /data/logs/error_tp_web.log;
}

修改重写规则

rewrite  ^(.*)$  /index.php?s=$1  last;

检测nginx配置文件,重启nginx

sudo /usr/sbin/nginx -t
sudo  /usr/sbin/nginx -s reload
原文地址:https://www.cnblogs.com/wangkongming/p/5517452.html