Rewrite Subdomains to Paths

1 view
Skip to first unread message

Kurtis Mullins

unread,
Mar 21, 2012, 4:15:00 PM3/21/12
to ng...@nginx.org
Hey,

Is it possible to rewrite subdomains to paths? I want to do something like this:


Thanks!
- Kurtis

Valentin V. Bartenev

unread,
Mar 21, 2012, 4:33:02 PM3/21/12
to ng...@nginx.org
On Thursday 22 March 2012 00:15:00 Kurtis Mullins wrote:
> Hey,
>
> Is it possible to rewrite subdomains to paths? I want to do something like
> this:
>
> x.example.com/foo/bar/ -> www.example.com/x/foo/bar/
>

server {
server_name ~^(?P<subdomain>.+)\.example\.com$;

location / {
return 301 http://www.example.com/$subdomain$request_uri;
}
}

wbr, Valentin V. Bartenev

_______________________________________________
nginx mailing list
ng...@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Reply all
Reply to author
Forward
0 new messages