Forum Discussion
Stanislas_Piro2
Jun 13, 2018Cumulonimbus
Please explain what you want to do...
in description, you talk about https:// and in irule, you redirect to http service
So :
- if the client requests http://abc.com --> you can redirect to http://www.abc.com without error
- if the client requests http://abc.com --> you can redirect to https://www.abc.com without error
- if the client requests https://abc.com --> you can redirect to https://www.abc.com but you can't prevent TLS error if you don't have a certificate for abc.com. TLS certificate if sent by the server before you can redirect...
You can try this code:
when HTTP_REQUEST {
set host [HTTP::host]
evaluate host starting with "www." if we need to insert it in redirect.
set redirectHost [expr {$host starts_with "www" ? [getfield $host ":" 1] : "www.[getfield $host ":" 1]"} ]
evaluate if service is http or https / host starts with "www." If one of these condition is false, prepend to the redirect URI https://$redirectHost
set redirectURI [expr {![PROFILE::exists clientssl] || !($host starts_with "www.") ? "https://$redirectHost" : ""}]
If path equals / change URI to "/XYZ.Web/Login.aspx"
append redirectURI [expr {[HTTP::path] equals "/" ? "/XYZ.Web/Login.aspx" : [HTTP::uri]}]
if the URI requires to redirect,redirect to $redirectURI, else, forward to pool as configured in virtual server.
if {!($redirectURI equals [HTTP::uri])} {
HTTP::redirect $redirectURI
}
}