skip to Main Content

I’m looking for a method to redirect visitors from https://site1.co.uk to https://site2.co.uk in HAProxy. I also need to redirect sub-pages (i.e. https://site1.co.uk/page1) to similar pages on site2.co.uk but using specific URLs. I have stuck a sample below of what I’d like to achieve if that helps…

Home redirect:
https://site1.co.uk -> https://site2.co.uk

Sub redirect:
https://site1.co.uk/first-page.html -> https://site2.co.uk/about-us.html

I’ve been searching for the last day or so for a simple solution to this problem and have been unable to find anything that does the trick.

I’m using HAProxy 1.5 (version required for a specific project) and any help would be much appreciated!

UPDATE

Things I’ve tried…had to remove HTTPS www.’s due to account limit.

redirect prefix site2.org.uk/subpage2/endresult2.html if { hdr(host) -i site1.org.uk }

redirect prefix site2.org.uk/subpage2/endresult2.html if { hdr(host) -i site1.org.uk/site1page.html }

Line 1: redirects correctly.

Line 2: End result is site2.org.uk/subpage2/endresult2/site1page.html – this is incorrect and should not include the site1page.html page on the end.

End result should be site2.org.uk/subpage2/endresult2 – this is how it I would like it to appear.

The server that HAProxy is on also serves multiple sites with different URLs. The above code is also redirecting them yet it shouldn’t interact. How can I prevent this from happening?

UPDATE 2

I’ve noticed that when I enable a redirect, it’s affecting my other sites which route through HAProxy and not just the one I’m trying to redirect (i.e. site1)

2

Answers


  1. Chosen as BEST ANSWER

    Although not technically the answer I wanted...I realised that I could redirect using the httpd configuration file instead of HAProxy. In the end that was the easiest option for a newbie like myself. Time will tell if this performs well...


  2. if you need to redirect your URL, you can check below link:

    How to redirect URL with HAProxy

    in haproxy you should use configuration like above

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search