redirect error 500 with context

Good,

I am trying to create an irule in F5 that after a 500 error in one url redirects me to another but keeping all the uri.

For example:

https://portafirmas.es/portafirmas/informeFirma?idRequest=121231&idDocument=sdasdas

Redirect to

https://portafirmasng.es//pfirmaNG/downloadReport?idRequest=121231&idDocument=sdasdas

So far I have these ideas but none of them fulfill my purpose.

when HTTP_REQUEST {

set uri [HTTP :: uri]

}

when HTTP_RESPONSE {

if {([HTTP :: status] eq “500”)} {

HTTP :: redirect “https: //portafirmasng.justicia.junta-andalucia.es$uri”

}

}

But I don’t get the result I want.

Good,

In the end I found the solution, I leave it here in case it is valid for someone.

when HTTP_REQUEST {

if { [HTTP::uri] starts_with “/portafirmas/informeFirma” } {

set uring “/pfirmaNG/informeFirma?[HTTP::query]”

}

if { [HTTP::uri] starts_with “/portafirmas/downloadFile” } {

set uring “/pfirmaNG/downloadFile?[HTTP::query]”

}

if { [HTTP::uri] starts_with “/portafirmas/downloadSign” } {

set uring “/pfirmaNG/downloadSign?[HTTP::query]”

}

}

when HTTP_RESPONSE {

if { ([HTTP::status] eq “500”) } { HTTP::redirect “https://portafirmasng.justicia.junta-andalucia.es$uring”

}

}

Salu2