0

I'm having trouble understanding how to combine a redirect with an URL rewrite in HAProxy. Specifically I have this URL

https://www.example.com/en/blog

that I need to rewrite to

http://blog.example.com/en

So I need to change the host and scheme, and remove the /blog path prefix in one step.

0

I solved it by combining reqrep and redirect like so

use_backend website-blog if { path_reg \/?(.*)\/blog }

backend website-blog
  reqrep        ^([^\ :]*)\ \/?(.*)\/blog\/?(.*)    \1\ /\2/\3
  redirect      prefix http://blog.example.com    code 301

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.