Thursday, 15 September 2011

regex - nginx rewrite rule for wildcard domain with same subdomain -



regex - nginx rewrite rule for wildcard domain with same subdomain -

i'm hoping can help utterly confused. i've spent ages looking online, i'm lost in syntax, , sense i'm trying over-complicate things.

anyway, do, have nginx rewrite status points domains same images subdomain generic images folder own subfolder.

examples:

images.domain1.com points /root/to/nginx/images/domain1.com/ images.domain2.com points /root/to/nginx/images/domain2.com/

i found article used server_name="~^(?<sub>.+)\.domain\.tld$" , pointed root /root/to/nginx/domain.com/$sub - when tried different combinations re-adjust regex server_name="~images\.(?<domain>)$" , point /root/to/nginx/images/$domain, didn't rewrite successfully.

many can shed lite on this.

the server_name directive doesn't take equals sign. capture grouping empty.

you should instead utilize server_name ~^images\.(?<domain>.+)$;

the path right (/root/to/nginx/images/$domain).

regex mod-rewrite nginx

No comments:

Post a Comment