Forum Discussion
Grayson_149410
Nimbostratus
Sep 29, 2015irule remove "www."
Does anyone have an iRule that will remove the "www." part of a URL? I tried the following iRule, but it does not work.
when HTTP_REQUEST {
if { [HTTP::uri] equals "https://www.abc.xyz.com" } {
...
IheartF5_45022
Nacreous
Sep 30, 2015From an SEO perspective, a 301 redirect would be best;-
when HTTP_REQUEST {
if {[string tolower [HTTP::host]] starts_with "www." } {
HTTP::respond 301 Location "https://[substr [HTTP::host] 4][HTTP::uri]" content "" noserver
return
}
}
Alternatively, if you want the browser to continue to display the www. Host variant, you may want to proxy the request with a modified Host header rather than redirecting;
when HTTP_REQUEST {
if {[string tolower [HTTP::host]] starts_with "www." } {
HTTP::host [substr [HTTP::host] 4]
}
}
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
