Forum Discussion
UniFirst1_22521
Nimbostratus
Jan 14, 2019Using an iRule to redirect with a 301 response code
Trying to redirect using a iRule first removing any www from the header and sending back a 301 response. I have the following iRule for removing the www from the header. However, not sure how to do t...
CharlesCS
Cirrus
Jan 14, 2019Given that you want to remove a fixed-length string from the start of the host name, either of the following may be simpler and more efficient than using the 'findstr' command:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] starts_with "www." }
{
use one or the other but not both
HTTP::respond 301 "Location" "https://[substr [HTTP::host] 4][HTTP::uri]"
HTTP::respond 301 "Location" "https://[string range [HTTP::host] 4 end][HTTP::uri]"
}
}
The 'substr' command skips the first four characters of the host name (i.e. ";), as does the 'string range' command.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
