F5 is upgrading its customer support chat feature on My.F5.com. Chat support will be unavailable from 6am-10am PST on 1/20/26. Refer to K000159584 for details.

Forum Discussion

Perch_261628's avatar
Perch_261628
Icon for Nimbostratus rankNimbostratus
Apr 28, 2016

iRule question?

I'm trying to write an iRule that take a shorter URL and expand it while adding the last 9 characters to the end of it.

 

So as an example when someone browses to:

 

http://website.ca/admn/012345678

 

Note: The last 9 characters (in this example= 012345678) are variable and always different depending on the user.

 

I then want the URL to redirect to this longer URL while adding the variable 9 characters to the end of the URL after ID=

 

https://website.ca/AppXtender/ISubmitQuery.aspx?DataSource=BPROD&appname=B-S-ADMN&ID=012345678

 

I've been trying to tweak the following iRule without success as I'm unsure what I should be putting into "string range", does anyone have any suggestions?

 

when HTTP_REQUEST { set uri [HTTP::uri] switch -glob [string tolower [HTTP::uri] ] { "/admn/*" { HTTP::uri "/AppXtender/ISubmitQuery.aspx?DataSource=BPROD&appname=UM-S-ADMN&ID=[string range $uri 5 end]" } } }

 

2 Replies

  • Hello,

    Maybe an irule that the below one can fit your needs :

    when HTTP_REQUEST { 
        set uri [HTTP::uri] 
        switch -glob [string tolower [HTTP::uri] ] { 
            "/admn/" { 
                HTTP::uri "/AppXtender/ISubmitQuery.aspx?DataSource=BPROD&appname=UM-S-ADMN&ID=[getfield [HTTP::path] \"/\" 2]" 
            } 
        } 
    }
    
  • Hi Perch,

    I would try it with this one:

    when HTTP_REQUEST {
        option1
        set user_id [findstr [HTTP::uri] "/admn/" 6]
        option2
        set user_id [getfield [HTTP::uri] "/" 3]
        HTTP::respond 301 Location "https://website.ca/AppXtender/ISubmitQuery.aspx?DataSource=BPROD&appname=UM-S-ADMN&ID=$user_id" 
    }
    

    Ciao Stefan 🙂