Forum Discussion
Yanik
May 06, 2021Altocumulus
Redirect from WWW iRule
Hello all ! How can I redirect traffic from "www.example.com" to "https://example.com", I don't care if it's an iRule or policy. I tried iRules, policies, and nothing worked, all other redirects I...
May 06, 2021
Hi Yan,
1. string map
when HTTP_REQUEST {
if { [HTTP::host] starts_with "www." } {
HTTP::redirect https://[string map {www. ""} [HTTP::host]][HTTP::uri]
}
}
2. string range
when HTTP_REQUEST {
if { [HTTP::host] starts_with "www." } {
HTTP::redirect https://[string range [HTTP::host] 4 end][HTTP::uri]
}
}
3. getfield
when HTTP_REQUEST {
if { [HTTP::host] starts_with "www." } {
HTTP::redirect https://[getfield [HTTP::host] "www." 2][HTTP::uri]
}
}
4. substr
when HTTP_REQUEST {
if { [HTTP::host] starts_with "www." } {
HTTP::redirect https://[substr [HTTP::host] 4][HTTP::uri]
}
}
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