Nginx redirect preserving source hostname

Игнатенко Максим ignatenko at estaxi.ru
Mon Apr 3 08:17:19 UTC 2017


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. If I set up rewrite it works, but it rewrites url in 
browser too.

|if ($host = "www.anotherhost.com") { rewrite ^ 
http://www.somehost.com/someurl; }|


Is it possible to redirect preserving url ?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20170403/f203c1a1/attachment-0001.html>


More information about the nginx mailing list