Forum Discussion
NAWAZ_175679
Nimbostratus
Jun 13, 2018Modificatioin of irule to append www
I have my irule like this
when HTTP_REQUEST {
if { [HTTP::path] equals "/" } {
HTTP::redirect "/XYZ.Web/Login.aspx"
}
}
When user type https://www.abc.com and it works fine
but when user ...
Stanislas_Piro2
Cumulonimbus
Jun 13, 2018Please 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
}
}
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects