Forum Discussion
canuck
Altostratus
May 31, 2018URL redirect with multiple FQDNs
I am trying to define an iRule which will match any domain, adding www prefix and passing on. For example, if a user browses to http://abc.com or https://abc.com, redirects to https://www.abc.com. Same for def.com, jkl.com, etc.
I tried adding this:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] contains"www" } {
HTTP::redirect "https://www[HTTP::host][HTTP::uri]"
}
else {[HTTP::redirect] "https://www.[HTTP::host][HTTP::uri]"}
}
but it broke my test sites. Prefer to avoid specifying FQDNs as I need to match 70+ sites.
What am I missing?
Thank you
- Samir_Jha_52506
Noctilucent
Slightly modified the iRule.
when HTTP_REQUEST { if { [string tolower [HTTP::host]] contains"www" } { HTTP::redirect "https://[getfield [HTTP::host] ":" 1][HTTP::uri]" } else { HTTP::redirect "https://www.[getfield [HTTP::host] ":" 1][HTTP::uri]" } }
- canuck
Altostratus
That did it. Thank you!
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