For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

gdoyle's avatar
gdoyle
Icon for Cirrostratus rankCirrostratus
Oct 28, 2018

Need to use last 2 of domain name as URI Variable.

So I have a customer that has 15 or so different state based domains (think something like "mydomainFL.com", "mydomainTN.com", etc...). They have a requirement that incorporates the last two or three letters in their domain name as a portion of the redirected URI path. For example, if the user goes to the redirected URL/URI will be something like ";.

 

My question is, how, in an irule, can I have it pull the last two or three, and use those in the URI? Is that possible?

 

Thanks.

 

2 Replies

  • try to add like this irule:

    when HTTP_REQUEST {
        if { [HTTP::uri] eq "/newuser" } {
            set pos [expr {[string length [HTTP::host]] - 6}] 
            set url "[substr [HTTP::host] 0 pos].com/newuser/[substr [HTTP::host] pos 2]/start" 
        }
    }
    
  • gdoyle's avatar
    gdoyle
    Icon for Cirrostratus rankCirrostratus

    I think I figured out the answer to this. I can set a variable to be the length of the URL up to where I want it to define, then end it 4 before the end of the URL... So even if it is "mydomainCRAZY.com" I would do something like:

    set state [string range [HTTP::host] 8 end-4]

    That will define "CRAZY" as the ${state} variable, and I can insert that into the URI.

    Does that sound right?