How to redirect requests to a different domain/url with nginx

Solution 1:

The fastest way is to do a return instead of a rewrite. see here:

nginx redirect to www.domain

I just answered the linked question and tumbled upon this one.

Solution 2:

If you just want to redirect /something, and no other URL, then:

rewrite ^(/something.*) http://answares.com/examples_com$1 permanent;

That'll send a request for http://example.com/something/ to http://answares.com/examples_com/something/,

and, say, http://example.com/something/somewhere/page.html to http://answares.com/examples_com/something/somewhere/page.html