Forum Discussion

chungyu_16122's avatar
Icon for Altostratus rankAltostratus
Aug 01, 2011

How to append to URI

Hi eveyone



We have parts of our webite that are french, and when a user has access a, I need to append a /fr to certain sites.




I have created this irule but can not get it to work properly.






if { [string tolower [HTTP::host]] equals "" \


and [string tolower [HTTP::uri]] equals "science"} {


HTTP::uri "[HTTP:uri]/science/fr"









I have seen similar post regarding appending URI and based the rule off them but the 4th line is not accepted.










4 Replies

  • The first issue I see is the test...


    [string tolower [HTTP::uri]] equals "science"



    This should probably say...


    [string tolower [HTTP::uri]] starts_with "/science"



    Note the leading slash! The leading slash will always be included in HTTP:uri or HTTP:path.


    when HTTP_REQUEST {
       if { [string tolower [HTTP::host]] eq "" } {
            if { [string tolower [HTTP::uri]] starts_with "/science" } {
                HTTP::uri "/science/fr/[string range [HTTP::uri] 11 end]" }

    That should hopefully work.
  • Thanks alot, i will try it out, however, I forsee that I will have multiple sites that require the /fr but not every site. I have used matchclass operator to send traffic to different servers based off class list, could I do something similar? where I have a list of sites that need to have the /fr appended?



  • Hi Chungu,


    Yes you should be able to do that. If you are using v10 then you can use the class command (