Forum Discussion
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.
- Faruk_AYDIN
Nimbostratus
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
Cirrostratus
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?
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com