Forum Discussion

Mohamed_Lrhazi's avatar
Mohamed_Lrhazi
Icon for Altocumulus rankAltocumulus
Mar 21, 2013

Help improve http redirect iRule

I wrote this iRule so that my team could hopefully manage HTTP redirects easily, using a simple string data class with this format :

 

Host,URI,TARGET_URL,HTTP_CODE

 

Example:

 

www.example.com,/,http://target.site.com/path,302

 

*example.com,/foo/bar*,http://target.site.com/path/two,301

 

 

I need it to work on BigIP 10.0.

 

 

Any improvement suggestions highly appreciated.

 

https://gist.github.com/lrhazi/89b466ed2089cb19e6f9

 

 

Thanks a lot,

 

Mohamed.

 

 

2 Replies

  • *example.com,/foo/bar*,http://target.site.com/path/two,301is it possible to not use wildcard on http host? if so, i think by modifying data group data a bit we will be able to use "class match" command instead of comparing one by one.

    [root@ve10:Active] config  b class exact_class list
    class exact_class {
       "www.example.com/" { "http://target.site.com/path,302" }
    }
    
    [root@ve10:Active] config  b class starts_with_class list
    class starts_with_class {
       "bha.example.com/foo/bar" { "http://target.site.com/path/two,301" }
    }
    

    just my 2 cents
  • Yes, makes sense to sacrifice the wildcarding of hosts for performance. but in my version, I think 10.0, there does not seem to be a way to define a string data group as key and value, but just a list of strings....

    Maybe there is a way though.. am thinking about it....

    I added an improvement to the rule, where the 'taget" field is "eval"ed, so the user could put:

     *.example.com,/foo/bar*,http://target.site.com[HTTP::uri],301

    and it would behave like http classes do.