Forum Discussion
Stanislas_Piro2
Apr 23, 2017Cumulonimbus
Hi,
HTTP::uri and HTTP::path doesn't work in Policy evaluation (except if in clientless mode). during policy evaluation, uri is always /my.policy.
if you want to evaluate landing uri (URI the user entered before redirecting to /my.policy), you can work with this irule:
when ACCESS_SESSION_STARTED {
switch -glob -- [set landinguri [ACCESS::session data get session.server.landinguri]] {
"/ad/*" {
log local0. "Path before iRule: $landinguri"
set newlandinguri [string map -nocase {"/ad/" "/"} $landinguri]
ACCESS::session data set session.server.landinguri $newlandinguri
log local0. "Path after iRule: $newlandinguri"
log local0. "Logon type iRule: ad"
ACCESS::session data set session.custom.logontype "ad"
}
"/error/*" {
log local0. "Path before iRule: $landinguri"
set newlandinguri [string map -nocase {"/error/" "/"} $landinguri]
ACCESS::session data set session.server.landinguri $newlandinguri
log local0. "Path after iRule: $newlandinguri"
log local0. "Logon type iRule: error"
ACCESS::session data set session.custom.logontype "error"
}
}
}
this irule raise before VPE evaluation and you can then replace landinguri box with a box using branches:
ad : expr {[mcget {session.custom.logontype}] equals "ad"}
error : expr {[mcget {session.custom.logontype}] equals "error"}
if you want to rewrite all requests starting with /ad/ and /error/, you can use this irule (raise after HTTP_REQUEST and for all requests allowed by APM, you can use this irule:
when ACCESS_ACL_ALLOWED {
switch -glob -- [set uri [HTTP::uri]] {
"/ad/*" {
log local0. "Path before iRule: $uri"
set newuri [string map -nocase {"/ad/" "/"} $uri]
HTTP::uri $newuri
log local0. "Path after iRule: $newuri"
}
"/error/*" {
log local0. "Path before iRule: $uri"
set newuri [string map -nocase {"/error/" "/"} $uri]
HTTP::uri $newuri
log local0. "Path after iRule: $newuri"
}
}
}