Forum Discussion

3 Replies

  • Hi wskalandhar,

    the iRule needs to be extended a bit:
    when HTTP_REQUEST {
        if { not ([string tolower [HTTP::host]] starts_with "www") } {
            HTTP::redirect https://www.[getfield [HTTP::host] ":" 1][HTTP::uri]
        } else {
            HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
        }
    }
    

    Thanks, Stephan

  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus

    To take advantage of client-side caching (eliminating the redirect response for people who have already visited the site) and for SEO-reasons I would recommend sending a 301 instead of a 302:

    HTTP::respond 301 Location "https://www.[getfield [HTTP::host] ":" 1][HTTP::uri]"