Forum Discussion

mj16othman's avatar
mj16othman
Icon for Altostratus rankAltostratus
Feb 26, 2023

Reorder URL

Dears i need help !!!!!!!

I have a Url lets say  https://abc.com/product/#/motor/lead    when clients access this url , it assigns a "tmx"  in the middle of the url.

What i want is when the clients access the below url 

 

https://abc.com/product/?tmx=1676539770970#/motor/lead

 

Notice that “?tmx=1676539770970” is coming in the middle, while i want it to be at the end to be like this

 

https://abc.com/product/#/motor/lead?tmx=1676539770970

 

 

5 Replies

  • mj16othman It seems like this is the application inserting the text in the incorrect location of the URI if you have to reorder it. For simplicitys sake I recommend working on the application to insert the text in the appropriate location rather than doing this in an iRule as a bandaid. Now once you have explored that avenue of change and you are 100% that it cannot be done in the application then I would do it in an iRule. In order to configure this rule a bit easier, do you know the length that the string will always be or is this a string that is random in length but always starts with a ? and end with a #? Will this value only ever be integers from 0 t 9?

    • mj16othman's avatar
      mj16othman
      Icon for Altostratus rankAltostratus

      hi paulius 

       

      yes the string will always come after the  ?    The real length will  always be  13  integers example  tmx=1676539770970

      • Paulius's avatar
        Paulius
        Icon for MVP rankMVP

        mj16othman I think the following might do what you want but I'm not 100% so you might want to test this before putting it into production.

         

        when HTTP_REQUEST priority 500 {
        
            if { [HTTP::uri] starts_with "/product/?tmz=" } {
                set PATH_TO_MOVE [string range [HTTP::uri] [expr {[string first "?tmz=" [HTTP::uri]] + 5}] 13]
                set REMOVE_CONTENT [string map [list "\?tmz=[0-9]{13}" "" ] [HTTP::uri]]
                HTTP::redirect http://[HTTP::host]${REMOVE_CONTENT}/?tmz=${PATH_TO_MOVE}
            }
        
        }