insert subdomain into query

NginxNewComer nginx-forum at
Sun Dec 29 20:26:02 UTC 2013

I have setup a wildcard subdomain server(many subdomains)
server {
  listen       80;
  server_name ~(?<subdomain>.*).localhost;

I want to make the subdomain apart of the query in the backend

when we visit http://clothes.localhost/ 
backend query

or we visit http://jackets.localhost/large/blue/
backend query

I have tried for 5 hours now, Modifying rewrite and return as many ways
possible, Multiple errors such as

rewrite ^ http://$subdomain.localhost/script.php?x=$subdomain permanent;


etc etc(I have tried many more tweaks but didnt record all as I went along)

Thanks in advance for any intention to help or answers given.

Posted at Nginx Forum:,245906,245906#msg-245906

More information about the nginx mailing list