我已经定义了一个带有正则表达式匹配和重定向的新服务器块:
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?
试试这个 :
server {
listen 80;
server_name ~^homersimpson.(?<domain>.*)$;
return 301 $scheme://$domain/apply?ref=thesimpsons;
}