简体   繁体   English

nginx位置规则中的两个通配符

[英]nginx two wildcards in location rule

I have this location rule in my config file and what I'm trying to do is to get two params from the URL . 我的配置文件中有此位置规则,而我想做的就是从URL获取两个参数。

I want to accept all characters including Latin, Cyrillic etc. 我想接受所有字符,包括拉丁语,西里尔字母等。

The problem is that echo $_GET["video_name"]; 问题是echo $_GET["video_name"]; returns both params like first_param/second_param and echo $_GET["not"]; 返回两个参数,例如first_param/second_param并返回echo $_GET["not"]; returns undefined . 返回undefined

What am I doing wrong here? 我在这里做错了什么?

location ~ ^/related/(.*)$/(.*)$ {
    try_files $uri $uri/ /api/related.php?video_name=$1&not=$2;
}

I figured out that the first $ is breaking the rule. 我发现第一个$违反了规则。 It should be smth like this. 应该是这样。

location ~ /related/(.*)/(.*)$ {
    try_files $uri $uri/ /api/related.php?video_name=$1&not=$2;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM