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
One way to do it is using a perl subroutine to change the underscores to hyphens. You need to compile nginx with perl unless it isn't included already. This isn't a fully working solution, but it might get you going in the right direction:
In nginx.conf add this within the http section:
Then in the location you may call the subroutine:
I prefer the ngx_lua module myself.
First line (gsub) changes all "_" to "-"
Second line (sub) changes first "/idx" to "/property"
Third line is obvious