Welcome! Log In Create A New Profile

Advanced

smarter permanent redirects

Posted by richard-willowit 
smarter permanent redirects
May 25, 2015 09:11PM
Hello,

Pretty much a nube to this. Hopefully somebody can help me out with some questions.

Our client is going to migrate their website to our services - we provide the backend, and there is an all new frontend.

They have a fantastic reputation in their industry, sell a few thousand products, and have hundreds of links to their products as well as prominently featuring in Google searches. Obviously, we don't want that to be affected at all.

They will retain their current domain name, but the structure below that will probably change drastically. Simple redirects do not look like they will cut it.

e.g.
www.xyz.com/path1/product1 may need to redirect to www.xyz.com/newpath1/product1
www.xyz.com/path1/product2 may need to redirect to www.xyz.com/newpath2/product2
www.xyz.com/path2/product3/variant may need to redirect to www.xyz.com/newpath1/product4

Is there any way to get nginx to call a program, or a very advanced rountine, to best guess a redirect? The information about where to redirect could very well end up being stored in an sql table.

Or, is the only real possibility to make

www.xyz.com/path1/x redirect to www.xyz.com/redirectorpage/path1/x

and write a handler there?


Also, is there any difference between using "rewrite" to accomplish a redirect, or returning a 301 permanent redirect???

Thankyou in advance for any guidance,

Richard
Re: smarter permanent redirects
May 26, 2015 03:00AM
Such amount of redirects can be best done with 'map', if you want dynamic redirects then you need Lua, a table read from sql into memory and an optimized Lua routine which does the rewrite (so not map).

Map is static until nginx is reloaded, with Lua you can read sql data, store in ram and periodically re-read sql for a refresh.
https://groups.google.com/forum/#!forum/openresty-en

But all in all not a job to be done in 5 min...

---
nginx for Windows http://nginx-win.ecsds.eu/
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 208
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready