Forum Discussion

Rajesh_74831's avatar
Rajesh_74831
Icon for Nimbostratus rankNimbostratus
Jul 25, 2014

need to redirect http://abc.com to www.abc.com

I would need help to setup an irule which can redirect all requests to http://abc.com to www.abc.com.

 

Thanks

 

-Rajesh

 

5 Replies

  • when HTTP_REQUEST {
        if { [HTTP::host] eq "abc.com" } { HTTP::redirect http://www.abc.com }
    }
    
  • when HTTP_REQUEST {
        if { [HTTP::host] eq "abc.com" } { HTTP::redirect http://www.abc.com }
    }
    
  • We use an iRule on multiple VIPs, so we went with this instead:

    when HTTP_REQUEST {
      if {not ([HTTP::host] starts_with "www")} {
        HTTP::redirect "http://www.[HTTP::host][HTTP::uri]"
      }
    }