我想在我的配置中检查查询字符串。如果匹配加载某个页面。如果不匹配,则重定向它。所以我这样写配置:
...
location / {
if ($args ~ "api_url") {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
index index.html;
try_files $uri /page_cache/$uri /page_cache/$uri/ /page_cache/$uri.html @puma;
break;
}
rewrite ^ http://domain.com permanent;
}
...
Run Code Online (Sandbox Code Playgroud)
但它不起作用,因为我不能在 if 中使用所有这些指令。
我尝试break在 if 中只使用一个,但它也不起作用。
我怎么能做到这一点?
谢谢。
nginx ×1