For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

remove www

Problem this snippet solves:

We basically want to redirect www.ecpurchasing.com to https://ecpurchasing.com. Right now the rule in the load balancer simply redirects http to https. External clients that use the Referrer URL for authentication validation only accepts request coming from https://ecpurchasing.com without “www”.

this virtual supports a number of sites using a SAN cert. The SAN cert includes ecpurchasing.com as well as www.ecpurchasing.com but the application needs to receive requests just from https://ecpurchasing.com.

How to use this snippet:

when HTTP_REQUEST { if {[string tolower [HTTP::host]] starts_with "www.ecpurchasing";} { #HTTP::redirect "https://[findstr [string tolower [HTTP::host]] "www.ecpurchasing"; 4][HTTP::uri]" HTTP::redirect "http://[string range [HTTP::host] 4 end][HTTP::uri]" } else { HTTP::redirect "https://[HTTP::host][HTTP::uri]" } }

Code :

when HTTP_REQUEST {
    if {[string tolower [HTTP::host]] starts_with "www.ecpurchasing"} {
       #HTTP::redirect "https://[findstr [string tolower [HTTP::host]] "www.ecpurchasing" 4][HTTP::uri]"
        HTTP::redirect "http://[string range [HTTP::host] 4 end][HTTP::uri]"
    } else {
        HTTP::redirect "https://[HTTP::host][HTTP::uri]"
    }
}

Tested this on version:

11.5
Published Mar 29, 2017
Version 1.0

1 Comment

  • this seems simple enough but broke my site when i applied it, all https stopped working and i get page cant be displayed. my irule is as follows:

     

    when HTTP_REQUEST {

      if {[string tolower [HTTP::host]] starts_with "www.jarvis"} {

        #HTTP::redirect "https://[findstr [string tolower [HTTP::host]] "www.jarvis" 4][HTTP::uri]"

        HTTP::redirect "http://[string range [HTTP::host] 4 end][HTTP::uri]"

      } else {

        HTTP::redirect "https://[HTTP::host][HTTP::uri]"

      }

    }