nginx location 路由的几个配置纪要

1:网上没有查到在线测试 nginx location 规则的网址

在服务器上可以通过 return 返回测试比如  把#号去掉

  # location   /admin.php(.*)
      # {
        
       #default_type    text/html;

       #  return 502 "服务正在升级,请稍rricc再试……";
      #}

可以通过 return 看到所访问的地址有没有进这个路由

2:tp5 未上线开发时一定要把debug 模式打开. 在/application/config 下边 把debug 和trace 两个项设置为true;  没有这个等于是睁眼瞎.

3:  yourcom/admin.php/index/index.html  这种方式访问出现404错误  如果通过yourcom/admin.php?s=/index/index.html  能访问

可以在/路由内重写规则

location / {

    if (!-e $request_filename) {


      rewrite ^/admin.php(.*)$ /admin.php?s=$1 last;  #这一条是添加 ?s=  .其中(.*) 括弧是圈起来的变量 为了让后边$1 使用 . 括弧内的.* 所有值 ,就是admin.php之后所有值  ^ 开始  $结束  
      rewrite  ^(.*)$  /index.php?s=$1  last;   # 这条规则是类似www.xxx.com/abc.html  ,直接把 abc.html加到后边那串/index.php?s=/abc.html  这是隐藏入口式访问....
break; } }

参考地址文章 https://www.cnblogs.com/sjzlai/p/10075270.html
原文地址:https://www.cnblogs.com/zuochanzi/p/11398624.html