Forum Discussion
Oxenburger_1420
Nimbostratus
Jan 30, 2014Create iRule to change URI Path to parse last directory
Hi,
I'm trying to create an iRule that matches URI starting with “eat9.raspberry.cheesecake.com/cache/_/(_)” to resolves to “eat9.raspberry.cheesecake.com/(*)” via the F5
i.e. “eat9.raspberry.che...
Oxenburger_1420
Nimbostratus
Jan 31, 2014Hi,
I couldn't get switch -glob working but will persevere.
I did manage to parse the last 2 directories of the uri + basename + query string. Turns out they wanted the /cache/1.1.201311042258/ stripped from the URI and parse the remaining directory including basename and query string.
e.g eat9.raspberry.pies.com/cache/1.1.201311042258/js/jquery.js” is changed to “eat9.raspberry.pies.com/js/jquery.js”
So this is what seems to work for this part.
elseif { ([HTTP::host] eq "eats9.raspberry.pies.com") && ([HTTP::uri] starts_with "/cache/") } {
set depth [URI::path [HTTP::uri] depth]
set last_dir [URI::path [HTTP::uri] 3 $depth]
set base [URI::basename [HTTP::uri]]
HTTP::uri "$last_dir$base?[HTTP::query]"
pool PL_eats9.media.pies.com_1444
}
This is what the entire iRule looks like for now. Or at least until I can retest switch.
when HTTP_REQUEST {
{ ([HTTP::host] eq "eats9.raspberry.pies.com") && ([HTTP::uri] starts_with "/API/v") } {
pool PL_eats9.pies.com_99
} elseif { ([HTTP::host] eq "eats9.raspberry.pies.com") && ([HTTP::uri] starts_with "/APIConfig") } {
pool PL_eats9.pies.com_99
} elseif { ([HTTP::host] eq "eats9.raspberry.pies.com") && ([HTTP::uri] starts_with "/myGateWay/v") } {
pool PL_eats9.pies.com_99
} elseif { ([HTTP::host] eq "eats9.raspberry.pies.com") && ([HTTP::uri] starts_with "/testAPI") } {
pool PL_eats9.pies.com_99
} elseif { ([HTTP::host] eq "eats9.raspberry.pies.com") && ([HTTP::uri] starts_with "/svc/") } {
pool PL_eats9.pies.com_99
} elseif { ([HTTP::host] eq "eats9.raspberry.pies.com") && ([HTTP::uri] starts_with "/pagedata/") } {
pool PL_eats9.pies.com_1443
} elseif { ([HTTP::host] eq "eats9.raspberry.pies.com") && ([HTTP::uri] starts_with "/pages") } {
pool PL_eats9.media.pies.com_1444
} elseif { ([HTTP::host] eq "eats9.raspberry.pies.com") && ([HTTP::uri] starts_with "/fonts") } {
pool PL_eats9.media.pies.com_1444
} elseif { ([HTTP::host] eq "eats9.raspberry.pies.com") && ([HTTP::uri] starts_with "/css") } {
pool PL_eats9.media.pies.com_1444
} elseif { ([HTTP::host] eq "eats9.raspberry.pies.com") && ([HTTP::uri] starts_with "/templates") } {
pool PL_eats9.media.pies.com_1444
} elseif { ([HTTP::host] eq "eats9.raspberry.pies.com") && ([HTTP::uri] starts_with "/js/") } {
pool PL_eats9.media.pies.com_1444
} elseif { ([HTTP::host] eq "eats9.raspberry.pies.com") && ([HTTP::uri] starts_with "/images") } {
pool PL_eats9.media.pies.com_1444
} elseif { ([HTTP::host] eq "eats9.raspberry.pies.com") && ([HTTP::uri] starts_with "/cache/") } {
set depth [URI::path [HTTP::uri] depth]
set last_dir [URI::path [HTTP::uri] 3 $depth]
set base [URI::basename [HTTP::uri]]
HTTP::uri "$last_dir$base?[HTTP::query]"
pool PL_eats9.media.pies.com_1444
} elseif { [HTTP::host] eq "eats9.raspberry.pies.com" } {
pool PL_eats9.pies.com_1443
}
}
Thanks,
Dave
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