Forum Discussion
ringoseagull_77
Mar 25, 2011Nimbostratus
irule to remove www. prefix from URIs
Hi,
I'm sure this has been covered but a search brings up a lot of threads using the same words
I need an irule which just strips out the www. from an http request, eg redirect www...
hooleylist
Mar 25, 2011Cirrostratus
Here you go:
when HTTP_REQUEST {
Check if the host starts with www.
if {[string tolower [HTTP::host]] starts_with "www."}{
Redirect with the www. prefix removed to the same URI
HTTP::redirect "http://[string range [HTTP::host] 4 end][HTTP::uri]"
}
}
If this is for HTTPS, your cert is only valid for example.com and the client requests www.example.com, this iRule won't prevent a cert mismatch warning. You'd also need to change the redirect from http:// to https://.
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