Welcome! Log In Create A New Profile

Advanced

Re: Redirect /olddir to /newdir

February 01, 2011 01:50AM
On Tue, Feb 01, 2011 at 01:44:13AM -0500, TECK wrote:

> Hi all,
>
> I need your suggestions to create a rewrite rule in nginx that will
> redirect the user from an old dir to the new one:
> http://domain.com/olddir/some/dir/ to
> http://domain.com/newdir/some/dir/
>
> location /newdir/ {
> try_files $uri $uri/ /newdir/index.php?$uri&$args;
> }
> location /olddir/ {
> rewrite ^ http://domain.com/newdir$request_uri? permanent;
> }
>
> The above rule does not work, it will redirect the user to
> http://domain.com/newdir/, instead of
> http://domain.com/newdir/some/dir/.
> If an user types the http://domain.com/olddir/some/dir/ url, nginx
> should automatically redirect him/her to
> http://domain.com/newdir/some/dir/. Right now, it brings the user to
> http://domain.com/newdir/.

location /olddir/ {
rewrite ^/olddir/(.*)$ http://domain.com/newdir/$1 permanent;
}


--
Igor Sysoev
http://sysoev.ru/en/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Redirect /olddir to /newdir

TECK February 01, 2011 01:44AM

Re: Redirect /olddir to /newdir

Igor Sysoev February 01, 2011 01:50AM

Re: Redirect /olddir to /newdir

TECK February 01, 2011 04:48PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 105
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready