Forum Discussion

dbauter's avatar
dbauter
Icon for Nimbostratus rankNimbostratus
Jul 11, 2018

IRule help with editing URI

Hello all. Trying to solve a problem with my rule. I have most of the iRule working, just it partially fails on certain entries. So for the client the website is mywebsite.com/abc. We redirect this automatically based on a datagroup which is pasted below:

 

when HTTP_REQUEST {
 if { [class match [string tolower [HTTP::uri]]  starts_with CLIENT-DATAGROUP ] } {
                  set client [string tolower [URI::basename [HTTP::uri]]]
                  HTTP::redirect "mywebsite.com/webcenter/portal/ProviderSearch?ProviderSearchConfig=ClientSite&SiteUrlSuffix=$client"
                  pool pool_MYPOOL
                  unset client

 

So for almost everything this works fine, the rule grabs the URI and puts it at the end of the redirect and the users get the correct site. The problem comes as there are a couple clients that use mywebsite.com/abc/search. My grab and redirect above redirects the client to mywebsite.com/webcenter/portal/ProviderSearch?ProviderSearchConfig=ClientSite&SiteUrlSuffix=search

So what I really need to do is just grab the first path in the URI, and add it onto the end of my needed site. The first path does vary in length based on client.

I tried some depth and path strings but haven't had any luck. It seems like there should be a simple solution but I'm just having some problems working it out. Thanks for any assist.