nginx重定向不包括查询字符串

问题描述 投票:0回答:1

我已经定义了一个带有正则表达式匹配和重定向的新服务器块:

server {
  listen 80;
  server_name ~^homersimpson.(?<domain>.*)$;
  rewrite ^ $scheme://$domain/apply?ref=thesimpsons redirect;
}

但卷曲后的URL没有查询字符串?

curl -w "%{url_effective}\n" -I -L -s -S https://homersimpson.domain.com -o /dev/null 
https://homersimpson.domain.com/

如何用查询字符串重写URL?

nginx nginx-config
1个回答
1
投票

试试这个 :

server {
  listen 80;
  server_name ~^homersimpson.(?<domain>.*)$;
  return 301 $scheme://$domain/apply?ref=thesimpsons;
}
© www.soinside.com 2019 - 2024. All rights reserved.