Forum Discussion
UniFirst1_22521
Nimbostratus
Feb 21, 2019301 redirect replacing www if present
Trying to create an iRule that will redirect HTTP to HTTPS and remove example incoming would be http://www.unifirst.ca and it would be redirected to https://unifirst.ca with a 301 response not a 302...
PeteWhite
Employee
Feb 21, 2019Try this:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] starts_with "www." } {
set host [ string map {'www.' ''} [HTTP::host] ]
HTTP::redirect "https://$host[HTTP::uri]"
} else {
HTTP::redirect "https://[HTTP::host][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