Forum Discussion

Michiel_61345's avatar
Icon for Nimbostratus rankNimbostratus
Apr 18, 2012

class match hostname in 10.2.1 irule




My website also has some country specific domain registration addresses. Customers visiting my website on a regional address need to be routed to my .com address and get my website shown.



IMHO, most decent way to do this is to use a data group for this, put in the country specific domain names and match the domain name request against the data group entries and do a redirect.






I've created a string type data group named "website_aliases"


Filled it with string/values equal to domainname/pool (pool is not used as an reference but each string needs a value), a couple of examples: pool_mycomp pool_mycomp pool_mycomp



The in the irule:





set host [string tolower [HTTP::host]]


set uri [string tolower [HTTP::uri]]



switch -exact $host {


"" {


pool pool_mycomp




if {[class match $host equals website_aliases]} {


HTTP::redirect }







Irule is accepted so contains no syntax errors.


Still after synch, when trying in a browser , it is reinitialised


Any of the aliases also don't work either so is not redirected to



Any ideas?

3 Replies

  • e.g.

    [root@ve1023:Active] config  b virtual bar list
    virtual bar {
       snat automap
       pool pool_mycomp
       ip protocol 6
       rules myrule
       profiles {
          http {}
          tcp {}
    [root@ve1023:Active] config  b class website_aliases list
    class website_aliases {
    [root@ve1023:Active] config  b rule myrule list
    rule myrule {
       when HTTP_REQUEST {
       if { [class match -- [HTTP::host] equals website_aliases] } {
          HTTP::redirect ""
    [root@ve1023:Active] config  curl -I
    HTTP/1.1 200 OK
    Date: Wed, 18 Apr 2012 13:21:10 GMT
    Server: Apache/2.2.3 (CentOS)
    Last-Modified: Fri, 11 Nov 2011 14:48:14 GMT
    ETag: "4183e4-3e-9c564780"
    Accept-Ranges: bytes
    Content-Length: 62
    Content-Type: text/html; charset=UTF-8
    [root@ve1023:Active] config  curl -I
    HTTP/1.0 302 Found
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
  • Hmm, in you're rule you specify an "--" in the class match, why is that?:


    if { [class match -- [HTTP::host] equals website_aliases] }



    Furthermore interesting that you're setup works...







  • -- Terminates option processing (useful if the or begins with a hyphen).class wiki





    your irule is not working since you are not able to mix switch with if-clause likes that.



    hope this helps.