Forum Discussion
Kai_Wilke
Feb 04, 2019MVP
Hi Goldz,
your iRule will do the trick.
Personally I would prefer to use quotation marks to clearly define the start and end of embedded string values.
when HTTP_REQUEST {
HTTP::redirect "https://[getfield [HTTP::host] ":" 1]:8080[HTTP::uri]"
}
In addition you may check if a 301 "Permanent Redirect" would be suitable for your website, so that you save a round trip on subsequent HTTP requests.
when HTTP_REQUEST {
HTTP::respond 301 "Location" "https://[getfield [HTTP::host] ":" 1]:8080[HTTP::uri]"
}
Also keep in mind, that sending a
[HTTP::host]
is only required for HTTP/1.1 requests. To support HTTP/1.0 requests, you may want to replace the [getfield [HTTP::host] ":" 1]
syntax with a hardcoded string. You could also mix a dynamic redirect based on available [HTTP::host]
values and use a hard coded string as a fall back by using a if-then-else syntax.
when HTTP_REQUEST {
if { [HTTP::host] ne "" } then {
HTTP::respond 301 Location "https://[getfield [HTTP::host] ":" 1]:8080[HTTP::uri]"
} else {
HTTP::respond 301 Location "https://www.mysite.com:8080[HTTP::uri]"
}
}
Cheers, Kai