Redirect based on part of path
I need to have a single vhost name (this.example.com) going to multiple applications depending on the first part of the path extension, then need to eliminate that first part of the path extension while caring on the rest of the URI.
Example: http://this.example.com/documents/dcm/viewer.asp Goes to
http://this.example.com/logs/error/errormanager.asp Goes to
http://this.example.com/reports/report/viewer.asp Goes to
I have this so far but it is not working. There may be an easier way than irule that I am not familiar with.
when HTTP_REQUEST { if { [HTTP::host] equals "this.example.com" } { if { [string tolower [HTTP::path]] starts_with "/documents/" } { HTTP::redirect "serverA:8080" [string trimleft [HTTP::uri] /documents] } elseif { [string tolower [HTTP::path]] starts_with "/logs/" } { HTTP::redirect "serverB" [string trimleft [HTTP::uri] /logs] } elseif { [string tolower [HTTP::uri]] starts_with "/reports/" } { HTTP::redirect "serverC" [string trimleft [HTTP::uri] /reports] } else { pool http://this.example.com [HTTP::uri] } } }