Rewrite Rule

Im am currently using heicontech rewrite software to apply the following rule,

RewriteRule ^/(ca)-(eng|fre)/(card)/?$ /$2/store/redirect.cfm?sectionID=etc/gift/display.cfm=$3 [I,L]

I would like to use irule on the F5 but i am not sure how to.

Thank you

can you try this out:

when HTTP_REQUEST { 
   if {[regsub {^/(ca)-(eng|fre)/(card)/} [HTTP::uri] \ 
     {/\2/store/redirect.cfm?sectionID=etc/gift/display.cfm=\3} \ 
     newUri]} { 
        HTTP::redirect http://[HTTP::host]$newUri 
   }  
 }

I’m not really sure on what your RewriteRule does as I don’t have much exposure with mod_rewrite. If the iRules didn’t work, pls let us know what your RewriteRule does.

You could also do this with string functions. The i flag is for case insensitive matching, so you could set the URI to lower case and then redirect based on the requested URI:

when HTTP_REQUEST { 
  
     Check the requested URI 
    switch [string tolower [HTTP::uri]] { 
  
       "/ca-eng/card" - 
       "/ca-eng/card/" { 
           Request was for eng 
          HTTP::redirect "http://[HTTP::host]/eng/store/redirect.cfm?sectionID=etc/gift/display.cfm=card" 
       } 
       "/ca-fre/card" - 
       "/ca-fre/card/" { 
           Request was for fre 
          HTTP::redirect "http://[HTTP::host]/fre/store/redirect.cfm?sectionID=etc/gift/display.cfm=card" 
       } 
       default { 
           Take some default action?  
       } 
    } 
 }

Aaron