Welcome! Log In Create A New Profile

Advanced

nginx redirect

Posted by endymon 
nginx redirect
July 14, 2011 11:04PM
Hello,

Is there a simple way to redirect a request to another domain?

Say nginx is running on http://bar.com
uri request is /foo/[http://new.url.org]

I want the user to be directed to http://new.url.org

The rewrite command only seems to ever handle the uri portion correctly, so no matter what I try it redirects to http://bar.com/foo/http://new.url.org so basically it is doing nothing.

I'm trying to muck around with rewrite_by_lua but not having much better success unless I hard code the url into ngx.redirect()

Any ideas? I bet its something simple I've overlooked.
Re: nginx redirect
July 15, 2011 06:45AM
Hi,

I am not sure if I understand your request completely, but here's what I'd try:

rewrite ^/foo(.*)$ http://new.url.org$1 permanent;

or

rewrite ^/foo http://new.url.org permanent;

Andrejs
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 283
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready