Hi,
Is is possible to achieve the below scenario.
URL: www.example.com/xyz/xyz.do?asar=equal?x=xyzw.xyzw.abcd
The requirements:
- Check if the URL start with “www.example.com/xyz/xyz.do?asar=equal?x=”.
- Replace the second “?” with “&”.
- Encode anything after “x=” using the base64 algorithm.
Thanks in advance.
BR,
Certainly not the only option, but the following should work:
set hosturi [string tolower [HTTP::host][HTTP::uri]]
if { $hosturi starts_with "www.example.com/xyz/xyz.do?asar=equal?x=" } {
set firstpart [string range $hosturi 0 [expr [string first "?x=" $hosturi] + 2]]
set secondpart [string rang $hosturi [expr [string first "?x=" $hosturi] + 3] end]
log local0. [string map {"?x" "&x"} $firstpart][b64encode $secondpart]
}
Thanks a lot kevin, I will test the iRule shortly and update you with the results .. Thanks again
BR
I made the below iRule which was mainly from your valuable inputs kevin and what I found in devcentral, and it seems to be working fine.
when HTTP_REQUEST {
if {[HTTP::uri] starts_with “/xyz/xyz.do?asar=equal?x=”} {
set uri [findstr [HTTP::uri] asar=equal?x= 15 ]
set enc_uri [b64encode $uri]
HTTP::redirect “www.example.com/xyz/xyz.do?asar=equal&x=$enc_uri”
log local0. “uri=$uri and Encrypted URI=$enc_uri”
}
}
Your inputs are really appreciated and helpful.
BR,