Forum Discussion
irule based redirection issue
Currently client sends URL request mylocalnet.us which is redirected to https with www code which is code 301. Once redirected to https://www.mylocalnet.us it is offloaded on ltm and request is sent to Web Server. Web server responds 302 https://www.mylocalnet.us/pages/variationroot.aspx which is used for language detection. If FR detected, server replies https://www.mylocalnet.us/fr/pages/default.aspx or with /en per language support. Actual purpose is to avoid multiple redirections on server side and perform these operations on ltm to expedite response time. Sharing with you unmodified code.
when HTTP_REQUEST {
STREAM::disable
redirect atd requests to atd site
if { [string tolower [HTTP::path]] equals "/atd/atd.xml" } {
HTTP::respond 301 "Location" "https://atd.mylocalnet.us/atd/atd.xml"
redirect http://mylocalnet.us to https://www.mylocalnet.us along with any uri
} elseif { [string tolower [HTTP::host]] equals "mylocalnet.us" } {
HTTP::respond 301 "Location" "https://www.mylocalnet.us[string tolower [HTTP::uri]]"
}
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
* 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