Forum Discussion
How to check for If not Redirect?
In below if statement how to check for if the request is not a redirect?
if { [HTTP::header is_redirect]} {}
4 Replies
- MichaelatF5
Employee
if { [HTTP::is_redirect] > 0 } {}
- Kevin_Stewart
Employee
Also:
if { not ( [HTTP::header exists Location] ) } { - Rajesh_A_142089
Nimbostratus
Kevin and Michael, Thanks for your response.
But it sounds like there is no better way if the request if a direct request or as a result of Redirect. I have tried below script and the result seems to be same(see below):
when HTTP_RESPONSE {
if { [HTTP::is_redirect] } {set a 1} if { [HTTP::header is_redirect] } {set b 1} if { [HTTP::header exists Location] } {set c 1}
if { not ([HTTP::is_redirect]) } {set a 0} if { not ([HTTP::header is_redirect]) } {set b 0} if { not ([HTTP::header exists Location]) } {set c 0}
set x [HTTP::is_redirect] set y [HTTP::header is_redirect] set z [HTTP::header exists Location]
set result [format "x=%s y=%s z=%s a=%s b=%s c=%s" $x $y $z $a $b $c]
HTTP::respond 200 content $result
}
RESULT: in any case the result is same as below! x=0 y=0 z=0 a=0 b=0 c=0
So I am just not sure if any of these conditions are working.
The redirection is trigger from another rule as below where myDNS is substituted: HTTP::respond 302 noserver Location "https://$uri"
- MichaelatF5
Employee
So why not just do what you are trying to accomplish on the inital response before checking for a redirect? What is the end goal?
when HTTP_RESPONSE { set a 0 set b 0 set c 0 if { [HTTP::is_redirect] } { set a 1 set b 1 set c 1 } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com