Forum Discussion
Jeff_Unger_1067
Nimbostratus
Dec 21, 2005Strip leading www
We have some special needs customers who do not realize that you can reach a website without adding a leading "www" to the URL. So, in order to accomodate those folks, we have aliases setup in DNS. ...
Dec 21, 2005
You'll need to specify the header name in your assignment.
HTTP::header replace []
Replaces the last occurrence of the named header with the string . This command performs a header insertion if the header was not present.
So, your code should look like this:
when HTTP_REQUEST {
if { [HTTP::host] equals "www.excel.gosolo.com" } {
HTTP::header replace "Host" "excel.gosolo.com"
}
}
Another option you could go with is a more generic approach if you have more than one domain to deal with.
when HTTP_REQUEST {
if { [HTTP::host] starts_with "www." } {
HTTP::header replace "Host" [string range [HTTP::host] 4 end]
}
}
Basically what this does is look to see if the Host header starts with "www." and if it does replace the header with everything after the "www." (index 4 to end).
-Joe
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
