Forum Discussion

mkoushki_127802's avatar
mkoushki_127802
Icon for Nimbostratus rankNimbostratus
Jan 03, 2006

redirect http://domain.com to http://www.domain.com

Hello

 

I am looking for simple statment for iRule in v9.x to redirect http://domain.com to http://www.domain.com

 

 

please advice

 

 

thanks
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    The command that you're looking for is HTTP::redirect.

    You would use this like:

    
    when HTTP_REQUEST {
      if {[HTTP::host] eq "domain.com" } {
        HTTP::redirect "http://www.domain.com"
      }
    }

    You can read more about this, and other iRules commands in the manual, here: Click here

    -Colin
  • Askar_Sattar_68's avatar
    Askar_Sattar_68
    Historic F5 Account
    well i am implementing your suggestion and i turn on the log,

     

    i have this in my iRule :

     

    when HTTP_REQUEST {

     

    if {[HTTP::host] eq "domain.org" } {

     

    HTTP::redirect "http://www.domain.org"

     

    log local0. "teri.org"

     

    }

     

    else {

     

    pool HTTP_TS

     

    log local0. "match"

     

    }

     

    }

     

     

    and resault is :

     

     

    Jan 6 15:14:00 tmm tmm[640]: Rule www : match

     

    Jan 6 15:14:00 tmm tmm[640]: Rule www : match

     

    Jan 6 15:14:00 tmm tmm[640]: Rule www : match

     

     

     

    so it seems, it by passed the first part of is statment

     

     

    do you have any idea why?

     

     

    thanks
  • Have you logged the value of [HTTP::host]? If you are getting the log statement with match in it, then the host value that is coming is is not "domain.org".

    log local0. "Host is [HTTP::host]"

    -Joe
  • log showes that , it is http://www.domain.com but in browser i still can see http://domain.com

     

     

    goal is to iRule enforce http://www.domain.com to client browser

     

     

    Thanks

     

     

    MK