Forum Discussion
Adam_Borders_10
Aug 18, 2011Nimbostratus
iRule Newbie learning - need validation
I want to validate the this iRule will do as I think. What I want to do is evaluate the request for a redirect to https. If the user connects to domain.com instead of www.domain.com I want to add the ...
hooleylist
Aug 18, 2011Cirrostratus
Hi Adam,
That looks like a good start. You may also want to handle requests with an IP address in the host header or no value:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host]] {
"www.*" {
Host started with "www.". Allow request without redirecting it?
}
"*[a-z]*" {
Host is not null and not an IP address
HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
}
default {
Host is null or an IP address
HTTP::redirect "https://default.example.com[HTTP::uri]"
}
}
}
Aaron
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