Forum Discussion
ShakN_167332
Nimbostratus
Aug 20, 2014I want to Redirect multiple Sites in a single Irule. please help me with the irule command.
I have mulitple sites where i want my LAN users should not to redirected to https when they use url with http. but when any internet users use http://abc.com than it should redirect to https://abc.co...
Yann_Desmarest
Cirrus
Aug 24, 2014Maybe you can try this
when HTTP_REQUEST {
if { [HTTP::host] equals "asites.abc.com" } {
switch -glob [HTTP::uri] {
"/xyz/finance" -
"/xyz/site2" -
"/xyz/site3" -
"/xyz/site4" -
"/xyz/site5" {
HTTP::redirect "http://asites.internet.abc.com[string map -nocase [list "/xyz/finance" "/sites/finance" "/xyz/test" "/sites/test"] [HTTP::uri]]"
}
default {}
}
}
You can also use datagroup to achieve what you want
when HTTP_REQUEST {
if { [HTTP::host] equals "asites.abc.com" } {
if { class match [HTTP::uri] equals mydatagroup } {
HTTP::redirect "http://asites.internet.abc.com[class lookup [HTTP::uri] mydatagroup]"
}
}
}
where datagroup of type string contains "/xyz/finance" with value "/sites/finance"
- ShakN_167332Aug 24, 2014
Nimbostratus
Will this irule work for my internet traffic redirection from https to http. when HTTP_REQUEST { if {[class match [IP::client_addr] equals InternalHosts]} { HTTP::redirect http://[HTTP::host][HTTP::uri] } else { switch -glob -- [string tolower [HTTP::host]] { "https://asites.abc.com/bseu/finance" { HTTP::redirect "http://asites.internet.abc.com/sites/finance" } } } - Yann_DesmarestAug 24, 2014
Cirrus
It will not work as HTTP::host give you only asites.abc.com as result. You can do the following : switch -glob -- [string tolower "[HTTP::host][HTTP::uri]"] { "asites.abc.com/bseu/finance" ... You can't know you are in https or http because you are in the HTTP_REQUEST event I suggest you to add the following : if {[PROFILE::exists clientssl] == 0}{ set proto "http" } else { set proto "https" } ... switch -glob -- [string tolower "$proto://[HTTP::host][HTTP::uri]"] { "http://asites.abc.com/bseu/finance" ... - ShakN_167332Aug 25, 2014
Nimbostratus
i get the below error when i try to create the data group which you suggested in irule. 01070151:3: Rule [test] error: line 3: [parse error: PARSE syntax 104 {syntax error in expression " class match [HTTP::uri] equals test ": variable references require preceding $}] [{ class match [HTTP::uri] equals test }]
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