Forum Discussion
Need some assistance with IRULE
Need some assistance with IRULE. If my pool mobileqa goes down need to seend a redirect for browser traffic to maintenance page. However if the traffic is coming from a mobile device the URL is different then a browser send a http status code 404 Not sure how to code the logic in one IRULE
URL will be something like Browser mobilet.test.com/www/* redirect to https://edepositqa.test.com/mobile/index.html Browser mobile.test.com/splash/* redirect to maintenace site redirect https://edepositqa.test.com/mobile/index.html Mobile Device mobile.test.com/webapp/* send status code 404
Sample when HTTP_REQUEST { if { [active_members Mobile-QA] < 1 } { HTTP::respond 404 Location [HTTP::header Location] } }
when HTTP_REQUEST { if { [active_members Mobile-QA] < 1 } {
HTTP::redirect "https://edepositqa.test.com/mobile/index.html"
return} } I have this IRULE Not sure how to code these in one IRULE nested
7 Replies
- Mui_64918
Cirrus
if { [HTTP::URI] starts_with "/www/" } { HTTP::redirect https://edepositqa.test.com/mobile/index.html return } elseif { [HTTP::URI] starts_with "/splash/"} { HTTP::redirect https://edepositqa.test.com/mobile/index.html return } else { HTTP::respond 404 Location [HTTP::header Location] return }
This should do the trick
- Cory_50405
Noctilucent
Your redirect should probably use code 302. 404 means not found, and isn't necessarily appropriate in this case.
- Michael_-_Harr1
Nimbostratus
I need to add the condition the Virtual server pool goes down as the condition
when HTTP_REQUEST { if { [active_members Mobile-QA] < 1 } {
Not sure how to incorporate the rest
if { [HTTP::URI] starts_with "/www/" } { HTTP::redirect https://edepositqa.test.com/mobile/index.html return } elseif { [HTTP::URI] starts_with "/splash/"} { HTTP::redirect https://edepositqa.test.com/mobile/index.html return } else { HTTP::respond 404 Location [HTTP::header Location] return }
- nitass_89166
Noctilucent
e.g.
when HTTP_REQUEST { if { [active_members Mobile-QA] < 1 } { if { [HTTP::URI] starts_with "/www/" } { HTTP::redirect "https://edepositqa.test.com/mobile/index.html" } elseif { [HTTP::URI] starts_with "/splash/"} { HTTP::redirect "https://edepositqa.test.com/mobile/index.html" } else { HTTP::respond 404 } } }- Michael_-_Harr1
Nimbostratus
Thank you. when I tried that IRULE received error undefined procedure error. 01070151:3: Rule [/Common/test] error: line 3: [undefined procedure: HTTP::URI] [HTTP::URI]
- nitass
Employee
e.g.
when HTTP_REQUEST { if { [active_members Mobile-QA] < 1 } { if { [HTTP::URI] starts_with "/www/" } { HTTP::redirect "https://edepositqa.test.com/mobile/index.html" } elseif { [HTTP::URI] starts_with "/splash/"} { HTTP::redirect "https://edepositqa.test.com/mobile/index.html" } else { HTTP::respond 404 } } }- Michael_-_Harr1
Nimbostratus
Thank you. when I tried that IRULE received error undefined procedure error. 01070151:3: Rule [/Common/test] error: line 3: [undefined procedure: HTTP::URI] [HTTP::URI]
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