Welcome! Log In Create A New Profile

Advanced

Re: Help with redirect from old to new URL

António P. P. Almeida
September 09, 2012 02:20PM
On 9 Set 2012 15h54 CEST, nginx-forum@nginx.us wrote:

> Hi,
>
> We are switching vendors for our property searches and each one
> formats the URLs a little bit differently. We already have 40,000+
> URLs indexed and want users to be 301 redirected to the new URL.
>
> The only difference in the URLs is a switch from underscores to
> hyphens, and from /idx/ to /property/.
>
> Here is the old URL:
> http://www.mysite.com/idx/mls-5028725-10425_virginia_pine_lane_alpharetta_ga_30022
>
> Here's the new URL:
> http://www.mysite.com/property/mls-5028725-10425-virginia-pine-lane-alpharetta-ga-30022
>
> Any ideas how to redirect all of these URLs without knowing what
> every one of the 40,000+ URLs are?
>
> Thanks,
> Keith

Use Lua: http://wiki.nginx.org/HttpLuaModule#ngx.re.gsub

Try:

location /idx {
set_by_lua $new_uri 'local newstr, n =
ngx.re.gsub(ngx.var.uri, "_", "-")
newstr, n = ngx.re.sub(newstr, "/idx/", "/property/")
return newstr';

return 301 $scheme://$host$new_uri;
}

Assuming you want to do a 301 redirect.

--- appa

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

Help with redirect from old to new URL

kfawcett September 09, 2012 09:54AM

Re: Help with redirect from old to new URL

Francis Daly September 09, 2012 10:38AM

Re: Help with redirect from old to new URL

kfawcett September 09, 2012 01:50PM

Re: Help with redirect from old to new URL

Francis Daly September 09, 2012 08:58PM

Re: Help with redirect from old to new URL

kfawcett September 09, 2012 10:29PM

Re: Help with redirect from old to new URL

Francis Daly September 10, 2012 07:40AM

Re: Help with redirect from old to new URL

kfawcett September 10, 2012 09:17AM

Re: Help with redirect from old to new URL

Francis Daly September 10, 2012 06:58PM

Re: Help with redirect from old to new URL

António P. P. Almeida September 09, 2012 02:20PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 280
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