On Fri, Sep 14, 2012 at 06:29:40AM +0200, Baptiste wrote: > On Fri, Sep 14, 2012 at 1:55 AM, Aaron Golub <[email protected]> wrote: > > Hi, > > So I've tried this a number of ways and so far I'm not have any luck (other > > than doing it via 301 redirect in Apache). I need to redirect some specific > > urls to other specific urls on a different site (re-branding and new servers > > setup, but we want to maintain our SEO juice for these specific domains. > > > > This is what I'm trying to achieve, imagine I have this url: > > > > http://www.olddomain.com/pageXXX/fileXXX > > > > > > and I want it to redirect to: > > > > http://www.newdomain.com/pageYYY/fileYYY > > > > > > www,newdomain.com is a seperate backend on my haproxy config. > > > > So I set this up in my front end: > > > > > > reqrep ^([^\ ]*)\ /pageXXX/fileXXX/(.*) \1\ /pageYYY/fileYYY\2 > > > > reqirep ^Host:\ www.olddomain.com Host:\ www.newdomain.com > > > > > > But it doesn't work. What am I doing wrong? > > > > Aaron > > > > > > -- > > Aaron Golub > > IT Director > > TurnHere, Inc. > > 415-820-1850 > > [email protected] > > > > > > Hi, > > What is it doing ??? > Not rewritting? > Could you provide apache logs on new server to see the Host header and > URL that has arrived on your backend server? > > Note that in some cases, you may have to rewrite some response too: > 301/302 Location Header, Cookie domains, etc... > In some cases, rewritting won't simply work, since the server would > send hardcoded URLs in the body, where HAProxy can't rewrite.
I suppose there is a "redirect code 301" rule later but that's not indicated here so I'm having a doubt. What I would do for this is just the URI rewrite (XXX->YYY) then a "redirect prefix http://www.newdomain.com/ code 301" to perform the redirect to the new domain. Regards, Willy

