Welcome! Log In Create A New Profile

Advanced

Re: Help with redirect from old to new URL

Francis Daly
September 09, 2012 10:38AM
On Sun, Sep 09, 2012 at 09:54:56AM -0400, kfawcett wrote:

Hi there,

> 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?

Within "location /idx/", dynamically generate the new url, and issue a
redirect to that. "dynamically" means "use one of the embedded languages,
or else talk to an external server".

An incomplete example using fastcgi and php is:

file /tmp/idx-fixup:
"""
<?php
$old = $_SERVER[REQUEST_URI];
$new = str_replace('_', '-', $old);
$new = substr_replace($new, '/property', 0, 4);

header("Status: 301 Moved Permanently");
header("Location: $new");
?>
"""

fragment of nginx.conf:
"""
location /idx/ {
include fastcgi.conf;
fastcgi_pass unix:php.sock;
fastcgi_param SCRIPT_FILENAME /tmp/idx-fixup;
}
"""

Good luck with it,

f
--
Francis Daly francis@daoine.org

_______________________________________________
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: 287
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