Forum Discussion

Michelle_Johns1's avatar
Michelle_Johns1
Icon for Nimbostratus rankNimbostratus
Jan 08, 2013

create an httpclass

i am trying to create an httpclass using tmsh, but am having trouble with the "glob" or "regex" to express a wildcard.

 

If I was in the GUI, I would create a new HTTPclass, click the checkbox to match on ANY host, then redirect to "www"

 

 

so, a user who typed "http://mydomain.com" would get redirected to "http://www.mydomain.com"

 

 

Here is what I have so far with the tmsh:

 

create ltm profile httpclass httpclass_www-redirect hosts add {glob: "*"} ....

 

 

3 Replies

  • Hi Michelle,

    I have not been doing F5 for long, but I think this is done with an Irule applied to the Virtual Server

    when HTTP_REQUEST { 
       if { [HTTP::host] starts_with "http://mydomain.com" } { 
         HTTP::redirect http://www.mydomain.com[HTTP::uri] 
       } 
    } 

    I dont know how to do this exact syntax with tmsh, but I think to do a redirect you need an Irule and apply this to the VS

    Graham
  • I just created one in the GUI and here's how it looks in tmsh;

    
    ltm profile httpclass test {
        app-service none
        cookies none
        defaults-from httpclass
        headers none
        hosts { glob:mydomain.com }
        paths none
        pool none
        redirect www.mydomain.com
    }
    
  • Note, if you wanted to match all hosts it would be 'hosts none' (funnily enough) but you don't want to match www.mydomain.com or your users will be stuck in an endless redirection loop.