Forum Discussion
CharlesCS
Jan 14, 2019Cirrus
Given that you want to remove a fixed-length string from the start of the host name, either of the following may be simpler and more efficient than using the 'findstr' command:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] starts_with "www." }
{
use one or the other but not both
HTTP::respond 301 "Location" "https://[substr [HTTP::host] 4][HTTP::uri]"
HTTP::respond 301 "Location" "https://[string range [HTTP::host] 4 end][HTTP::uri]"
}
}
The 'substr' command skips the first four characters of the host name (i.e. ";), as does the 'string range' command.