Nginx re-writes combining $server_name and $request_uri?
How can I write an nginx rewrite that will redirect traffic sent to the root of a site but not sent to paths below root?
In other words:
I want to rewrite any request to http://foo.bar.com to redirect to http://foobar.com
But any request for http://foo.bar.com/baz should go ahead and go there.
The below redirects any request to foo.bar.com because I'm matching on the host. I'm no rewrite master (especially on nginx), but I t开发者_Python百科hink I'd like to match on a concatenation of $server_name and $request_uri. I'm just not sure how to combine the two of them into one string to match against the way I can w/ Apache.
if ($host ~* ^foo\.bar\.com$){
rewrite ^.*$ http://foobar.com permanent;
}
rewrite ^/$ http://foobar.com permanent;
精彩评论