Forum Discussion

El-Guapo_29797's avatar
El-Guapo_29797
Icon for Nimbostratus rankNimbostratus
Sep 03, 2013

*Redirect http to https & add www to URL if none present*

Like to Redirect all http to https and add www to URL if not present already.

 

2 Replies

  • Try this:

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