Forum Discussion
rkrenzis
Nimbostratus
Apr 18, 2014HTTPS: Remove www. from hostname
This code appears to work for our HTTP (plain-text sites): when HTTP_REQUEST {
Check if the host starts with www.
if {([string tolower [HTTP::host]] starts_with "www.")} {
...
nitass
Employee
Apr 18, 2014www. is not explicitly removed from the display URL in the browser when the session is HTTPS
if you want to change display url, i think you have to use HTTP::redirect rather than HTTP::header.
config
[root@ve11a:Active:In Sync] config tmsh list ltm virtual bar
ltm virtual bar {
destination 172.28.24.10:443
ip-protocol tcp
mask 255.255.255.255
pool foo
profiles {
clientssl {
context clientside
}
http { }
tcp { }
}
rules {
qux
}
source 0.0.0.0/0
source-address-translation {
type automap
}
vs-index 4
}
[root@ve11a:Active:In Sync] config tmsh list ltm rule qux
ltm rule qux {
when HTTP_REQUEST {
if {([string tolower [HTTP::host]] starts_with "www.")} {
HTTP::redirect "https://[string range [HTTP::host] 4 end][HTTP::uri]"
}
}
}
test
[root@ve11a:Active:In Sync] config curl -Ik https://www.site1.com/something
HTTP/1.0 302 Found
Location: https://site1.com/something
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
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