Forum Discussion
ShakN_167332
Nimbostratus
Sep 10, 2014URI redirection issue with upper/lower case traffic
hi when user types lower case redirection works but when users types uppers it is not working..
eg: user come /bseu/finance it should redirect to /sites/finance this is working..now if user comes ...
Kevin_Stewart
Employee
Sep 12, 2014Try this:
when RULE_INIT {
set static::asitesext "asites.abc.com"
set static::asitesint "asites.internet.abc.com"
set static::aportalext "aportal.abc.com"
set static::aportalint "aportal.internet.abc.com"
set static::amyext "amy.abc.com"
set static::amyint "amy.internet.abc.com"
set static::aextranetext "aextranet.abc.com"
set static::aextranetint "aextranet.internet.abc.com"
set static::awww "awww.abc.com"
}
when HTTP_REQUEST {
if { [class match [IP::client_addr] equals InternalHosts] } {
log local0. "Redirecting based on InternalHosts match"
HTTP::redirect http://[HTTP::host][HTTP::uri]
} elseif { [class match [string tolower [HTTP::path]] starts_with test] } {
log local0. "Redirecting based on test match: [HTTP::uri]"
set origin [class match -name [string tolower [HTTP::path]] starts_with test]
set new [class match -value [string tolower [HTTP::path]] starts_with test]
set newuri [string map "$origin $new" [string tolower [HTTP::uri]]]
HTTP::redirect "https://[HTTP::host]${newuri}"
log local0. "New URI = $newuri"
} else {
log local0. "Replacing the HTTP Host header: [HTTP::host]"
switch -glob -- [string tolower [HTTP::host]] {
"asites.abc.com" {
HTTP::header replace Host $static::asitesint
STREAM::disable
}
"awww.abc.com" {
HTTP::redirect "https://aportal.abc.com"
STREAM::disable
}
"aportal.abc.com" {
HTTP::header replace Host $static::aportalint
STREAM::disable
}
"amy.abc.com" {
HTTP::header replace Host $static::amyint
STREAM::disable
}
"aextranet.abc.com" {
HTTP::header replace Host $static::aextranetint
STREAM::disable
}
}
}
}
when HTTP_RESPONSE {
if { [HTTP::is_redirect] && [string tolower [HTTP::header "Location"]] contains $static::asitesint } {
HTTP::header replace Location [string map "$static::asitesint $static::asitesext" [HTTP::header Location]]
STREAM::enable
} elseif { [HTTP::is_redirect] && [string tolower [HTTP::header "Location"]] contains $static::aportalint } {
HTTP::header replace Location [string map "$static::aportalint $static::aportalext" [HTTP::header Location]]
STREAM::enable
} elseif { [HTTP::is_redirect] && [string tolower [HTTP::header "Location"]] contains $static::amyint } {
HTTP::header replace Location [string map "$static::amyint $static::amyext" [HTTP::header Location]]
STREAM::enable
} elseif { [HTTP::is_redirect] && [string tolower [HTTP::header "Location"]] contains $static::aextranetint } {
HTTP::header replace Location [string map "$static::aextranetint $static::aextranetext" [HTTP::header Location]]
STREAM::enable
}
}
Just out of curiosity, do you have a custom STREAM profile defined?
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