全球主机交流论坛

标题: nginx 匹配动态地址规则怎么写 [打印本页]

作者: llcn168    时间: 2023-9-24 07:26
标题: nginx 匹配动态地址规则怎么写
像这种动态地址在nginx配置里面应该怎么匹配

/read.php?aid=1&cid=2

  1. location ~ .*read.php\?aid\=([0-9]+)\&cid\=([0-9]+)
  2. {
  3.         fastcgi_pass unix:/tmp/php-cgi-73.sock;
  4.         include enable-php-73.conf;
  5.         add_header Nginx-Cache "$upstream_cache_status";
  6.         fastcgi_cache cgi_one;
  7.         fastcgi_cache_valid 200 301 302 1d;
  8.         fastcgi_cache_valid 404 500 502 503 504 0s;
  9.         fastcgi_cache_valid any 0s;
  10. }
复制代码

这样好像匹配不到

来个大佬指导下


作者: greencloudvps    时间: 2023-9-24 07:32
问chatgpt




DMIT CN2GIA || DMIT 交流群 || 以针会友


作者: coolloves    时间: 2023-9-24 08:29
query_string 或者 args 匹配参数
作者: coolloves    时间: 2023-9-24 08:30
location 只负责  URL的匹配,参数需要单独在匹配
作者: iiss    时间: 2023-9-24 09:37
args[0] args[1]匹配参数




欢迎光临 全球主机交流论坛 (https://loc.isir333.eu.org/) Powered by Discuz! X3.4