tgk
tgk

Reputation: 4096

nginx redirect not including query string

I've defined a new server block with a regex match and redirect:

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

But the URL after curling is without the query string?

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

How do i rewrite the url with a query string?

Upvotes: 0

Views: 37

Answers (1)

Mohammad
Mohammad

Reputation: 660

try this :

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

Upvotes: 1

Related Questions