With the help of redirect url how can I do health check

redirect prefix URL code 301 if condn.
I have to check the health of the URL. If the URL is down then I have to redirect it to the maintenance page. How can I do that with haproxy?

Haproxy can health check backend server, however it will not health check remote servers unrelated to a backend.

You can create a dummy backend, with a server that you want to health check, and then use that in an ACL with nbsrv to make a conditional redirect. But this requires some minor legwork.

https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#7.3.2-nbsrv