pedinopa_170325
Oct 03, 2016Nimbostratus
irule to edit a URI
I have been working on an irule that will edit a URI string. What I need it to do is simply add a .domain.com after the first directory of the uri path and redirect to the new URI. I have it kind of working in that it is still very case sensative, but also it is not entering my switch statements. I have turned on HSL logging and can see that for some reason it is not entering or matching my switch statements. Some of the switch statements will only redirect. Below is what I have tried
incomming uri will be abc.domain.com/dirx/string what I want is dirX.domain.com/string
when HTTP_REQUEST {
HSL::send $hsl "This is the HTTP URI [HTTP::uri]"
HSL::send $hsl "This is the HTTP Path [HTTP::path]"
switch -glob { tolower [HTTP::path]} { "/DIR 1/" { set switches [string range [HTTP::uri] 19 end]
the switches will be everythi from the origional URI after the first directory HTTP::redirect "http://DIR1.DOMAIN.COM/$switches"
}
"/DIR 2" {
set switches [string range [HTTP::path] 15 end]
the switches will be everythi from the origional URI after the first directory
HTTP::redirect "http://Dir2.DOMAIN.COM/$switches"
}
"/DIR3*" {
set switches [string range [HTTP::path] 19 end]
the switches will be everythi from the origional URI after the first directory
HTTP::redirect "http://Dir3.DOMAIN.COM/$switches"
}
"/DIR4*" {
HTTP::redirect "http://DIR 4.DOMAIN.COM/"
}
"/DIR 5*" {
HTTP::redirect "http://DIR5.DOMAIN.COM"
}
"/DIR 6" {
HTTP::redirect "http://DIR6.DOMAIN.COM"
}
}