Forum Discussion
jonathan_voigt_
Nimbostratus
Nov 06, 2009url rewrite and routing
Hi,
I need have a single dns (VSA) capable of routing to multiple pools based on context (e.g. /en/ or /fr/ , however, the web app's on these pools is the same. One supports english a...
hoolio
Cirrostratus
Nov 09, 2009Here's something to start with:
when HTTP_REQUEST {
Make sure to add a OneConnect profile with this iRule
http://devcentral.f5.com/wiki/default.aspx/AdvDesignConfig/oneconnect
If language already exists from prior HTTP request
on same TCP connection, unset it
if {[info exists language]}{
unset language
}
Check requested path
switch -glob [HTTP::path] {
"/en/* {
set language "en"
pool pool_en
}
"/fr/*" {
set language "fr"
pool pool_fr
}
default {
No language prefix in the path,
so check if pool selector cookie has a value
if {[HTTP::cookie value "lang"] ne ""}{
Select pool based on cookie value
switch [HTTP::cookie value "lang"] {
"en" {
pool pool_en
}
"fr" {
pool pool_fr
}
}
}
}
}
If there was a language prefix in the URI, remove it
if {[info exists language]}{
Remove /en/ or /fr/ from the requested path
HTTP::path [string range [HTTP::path] 0 3]
}
}
when HTTP_RESPONSE {
Set a pool selector cookie in response
if {[info exists language]}{
HTTP::cookie insert name "lang" value $language path /
}
}
Aaron
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