Forum Discussion

8 Replies

  • The simplest way is you create an alias in your dns system to point domain.com to www.domain.com.

     

  • That is already in place, and works. What i need to do is when the request hits my BIG-IP i need to tack on the www. to the domain.com but only if it comes in as http://domain.com.
  • Or you can use an iRule:

     
     when HTTP_REQUEST { 
      
         Check if there was a host header value doesn't start with www. and does start with an alphabet character 
        if { not ([string match -nocase www.* [HTTP::host]]) && [string match -nocase a-z* [HTTP::host]]}{ 
      
           HTTP::redirect "http://www.[HTTP::host]" 
        } 
     } 
     

    Or something more specific:

     
     when HTTP_REQUEST { 
      
         Check if the host header value isn't www.domain.com 
        if { not ([string tolower [HTTP::host]] eq "www.domain.com") }{ 
      
           HTTP::redirect "http://www.domain.com" 
        } 
     } 
     

    Aaron
  • If they came into a specific url without the www prefix, would you just add the [HTTP::uri]?
  • If you rewrite the URI, the client wouldn't necessarily see the update to www.example.com and may end up making a request to https://example.com instead of https://www.example.com causing a cert mismatch error on the browser.

     

     

    Aaron
  • An alternative to the string match, though I'm not sure which is more optimal:

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