rewrite scheme for url redirect
sevy
nginx-forum at nginx.us
Thu Jan 27 17:17:20 MSK 2011
António P. P. Almeida Wrote:
-------------------------------------------------------
> On 26 Jan 2011 21h11 WET, nginx-forum at nginx.us
> wrote:
>
> > I'm going crazy with this since I can't get it
> working in any way...
> >
> > I have a subdomain on a server, let's call it
> images.site1.com,
> > dedicated to serve images. Due to some bandwidth
> limitation i got a
> > more capable server so the webpages will remain
> on site1.com but the
> > images will be moved to images.site2.com
> >
> > Since I had to change the names of images
> folders on the new server
> > now I need to rewrite the urls in order to fit
> my needs. Only the
> > webserver on site1.com runs NginX, so i need to
> do rewrite the
> > original ruls following a regular expression
> (regex) and do
> > something like:
> >
> >
> http://images.site1.com/oldfolderjpg/123456_1.jpg
> --rewrite-->
> >
> http://images.site2.com/newfolderjpg/12/34/new_ima
> ges/123456/123456_image_1_large.jpg
> >
> > - The first and most logic rewrite scheme I
> tought about is:
> >
> > rewrite
> >
> ^/oldfolder/([0-9][0-9])([0-9][0-9])([0-9][0-9])_(
> [0-9]).jpg$
> >
> http://images.site2.com/newfolder/$1/$2/new_images
> /$1$2$3/$1$2$3_image_$4_large.jpg
> > permanent
>
> On images.site1.com config try this:
>
> location /oldfolder {
> rewrite
> ^/oldfolder/(\d{2})(\d{2})(\d{2})_(\d)\.jpg$
> http://images.site2.com/newfolder/$1/$2/new_images
> /$1$2$3/$1$2$3_image_$4_large.jpg? permanent;
> }
I tried your solution but it has a semantic error cause nginx replies
nginx: [emerg] directive "rewrite" is not terminated by ";"
Because the regexp you posted has curly braces. So, following nginx wiki
(http://wiki.nginx.org/HttpRewriteModule#rewrite) i tried to wrap it
into both single and double quotes but with no result:
location /oldfolder {
rewrite '^/oldfolder/(\d{2})(\d{2})(\d{2})_(\d)\.jpg$'
http://images.site2.com/newfolder/$1/$2/new_images/$1$2$3/$1$2$3_image_$4_large.jpg?
permanent;
}
location /oldfolder {
rewrite "^/oldfolder/(\d{2})(\d{2})(\d{2})_(\d)\.jpg$"
http://images.site2.com/newfolder/$1/$2/new_images/$1$2$3/$1$2$3_image_$4_large.jpg?
permanent;
}
Nginx doesn't redirect my uri requests, so the problem still remains...
>
> --- appa
>
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://nginx.org/mailman/listinfo/nginx
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,169853,169902#msg-169902
More information about the nginx
mailing list