Forum Discussion
va_ma_158700
Nimbostratus
Nov 10, 2015iRule Syntax error
Hi - could someone please advise if they can assist resolve the syntax errors I am getting trying to write this iRule? thanks in advance
when HTTP_REQUEST { if { [HTTP::header "User-Agent"] contains "Windows " } { if {[HTTP::uri] eq "/checkversion?"} { HTTP::redirect "" log local0. "https://[HTTP::uri]"
}elseif {[HTTP::uri] eq "/register"} { HTTP::redirect "" log local0. "https://[HTTP::uri]" }elseif {[HTTP::uri] eq "/forgotPassword"} { HTTP::redirect "" log local0. "https://[HTTP::uri]" }elseif {[HTTP::uri] eq "/logvar/address-json"} { HTTP::redirect "" log local0. "https://[HTTP::uri]" } else{ HTTP::redirect "http://test.co.uk" }
log local0. "https://[HTTP::uri]" }
else
{ HTTP::redirect "http://test.co.uk" log local0. "https://[HTTP::uri]" } }
1 Reply
- Brad_Parker
Cirrus
What syntax error are you getting? Also, try using some
andstring tolower
rather than URI because that will include the query as well. Also, you are probably better off withHTTP::path
unless you want to match the path exactly. Also, you may be better with a switch rather than all these ifs.starts_withwhen HTTP_REQUEST { if { [HTTP::header "User-Agent"] contains "Windows " }{ if {[string tolower [HTTP::path]] starts_with "/checkversion"}{ HTTP::redirect "https://test.co.uk//deposit/registered" log local0. "https://[HTTP::host][HTTP::uri]" } elseif {[string tolower [HTTP::path]] starts_with "/register"}{ HTTP::redirect "https://test.co.uk//signup" log local0. "https://[HTTP::host][HTTP::uri]" } elseif {[string tolower [HTTP::path]] starts_with "/forgotPassword"}{ HTTP::redirect "https://test.co.uk//forgot-password" log local0. "https://[HTTP::host][HTTP::uri]" } elseif {[string tolower [HTTP::path]] starts_with "/logvar/address-json"}{ HTTP::redirect "https://test.co.uk//cashout" log local0. "https://[HTTP::host][HTTP::uri]" } else { HTTP::redirect "http://test.co.uk" } log local0. "https://[HTTP::host][HTTP::uri]" } else { HTTP::redirect "http://test.co.uk" log local0. "https://[HTTP::host][HTTP::uri]" } }or
when HTTP_REQUEST { if { [HTTP::header "User-Agent"] contains "Windows " }{ switch -glob [string tolower [HTTP::path]] { "/checkversion*" { HTTP::redirect "https://test.co.uk//deposit/registered" } "/register*" { HTTP::redirect "https://test.co.uk//signup" } "/forgotPassword*" { HTTP::redirect "https://test.co.uk//forgot-password" } "/logvar/address-json" { HTTP::redirect "https://test.co.uk//cashout" } default { HTTP::redirect "http://test.co.uk" } } log local0. "https://[HTTP::host][HTTP::uri]" } else { HTTP::redirect "http://test.co.uk" log local0. "https://[HTTP::host][HTTP::uri]" } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects