Forum Discussion
Glenn_Ruffus_10
Nimbostratus
Jan 07, 2008Force www in redirect if missing
I asked for and received help a couple of weeks ago regarding an iRule for forcing traffic on an *HTTPS* virtual server to include "www." at the beginning of the URL so that the requested URL would ma...
hoolio
Cirrostratus
Jan 07, 2008Like this?
when HTTP_REQUEST {
if {[HTTP::host] starts_with "www."} {
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
} else {
HTTP::redirect "https://www.[HTTP::host][HTTP::uri]"
}
}If there is a chance clients could make a request with the port number in the request (www.example.com:80), you could strip it out with getfield:
when HTTP_REQUEST {
if {[HTTP::host] starts_with "www."} {
HTTP::redirect "https://[getfield [HTTP::host] : 1][HTTP::uri]"
} else {
HTTP::redirect "https://www.[getfield [HTTP::host] : 1][HTTP::uri]"
}
}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
