Nginx redirect preserving source hostname

Francis Daly francis at daoine.org
Tue Apr 4 21:10:11 UTC 2017


On Mon, Apr 03, 2017 at 02:17:19PM +0600, Игнатенко Максим wrote:

Hi there,

> I have an NGINX as reverse proxy with PHP-fpm. Nginx is set up for
> serving www.somehost.com. I added another host www.anotherhost.com.
> Now I need to setup redirect in this way: If user type
> www.anotherhost.com then it redirects to www.somehost.com/someurl,
> but url in browser bar shouldn't change.

> Is it possible to redirect preserving url ?

A "redirect" is an "external rewrite", which asks the browser to make
a new request, and therefore change the url the browser shows.

If you want the browser not to make a new request, you need to handle
the request internally, within nginx, possibly by means of a proxy_pass
(if the desired resource is only available in another server{}).

Good luck with it,

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list