Forum Discussion
JeffRay_129268
Nimbostratus
Nov 22, 2015irule based redirection issue
Dear Members, I have a problem of language redirection loop. As per code mentioned below, Preferred Language is detected (i.e fr (french) in browser and redirected by ltm but this redirection goes in...
Matt_Dierick
Employee
Nov 23, 2015Like that
when HTTP_REQUEST {
STREAM::disable
if { [string tolower [HTTP::path]] equals "/" } {
if { ![HTTP::path] starts_with "/fr" && ([HTTP::header "Accept-Language"] starts_with "fr") } {
HTTP::redirect "https://www.mylocalnet.us/fr/pages/default.aspx"
}
else {
HTTP::redirect "https://www.mylocalnet.us/en/pages/default.aspx"
}
}
switch -glob [string tolower [HTTP::path]] {
"/en/sitemap.xml*" {
HTTP::uri "/en-sitemap.xml"
}
"/fr/sitemap.xml*" {
HTTP::uri "/fr-sitemap.xml"
}
}
}
when HTTP_RESPONSE {
catch and replace redirect headers
if { [HTTP::header exists Location] } {
HTTP::header replace Location [string map {"http://" "https://"} [string tolower [HTTP::header Location]]]
}
only look at text data
if { [HTTP::header Content-Type] contains "text" }
create a STREAM expression to replace any http:// with https:// for CDN
STREAM::expression {@http://bt.mylocal.ae@https://bt.mylocal.ae@ @www.mylocalnet.us@
@http://www.mylocalnet.us@https://www.mylocalnet.us@}
enable STREAM
STREAM::enable
}
}
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