Forum Discussion
theizer_91634
Nimbostratus
Sep 22, 2010simple redirection not working as expected - please help
I need requests to http://website.com to be redirected to http://www.website.com (which also needs to be redirected to https)
Here is the irule I created to do this:
when HTTP_REQU...
Joel_Moses
Nimbostratus
Sep 22, 2010The HTTP::uri function doesn't actually contain the hostname, just the path. You're looking for:
when HTTP_REQUEST {
if {[string tolower [HTTP::host]] equals "website.com"} {
HTTP::redirect https://www.website.com[HTTP::uri]
}
}
Do you also need http://www.website.com to redirect to https://www.website.com as well? If so apply this iRule to both the port 80 _and_ 443 VIPs:
when HTTP_REQUEST {
if {[string tolower [HTTP::host]] equals "website.com"} {
HTTP::redirect https://www.website.com[HTTP::uri]
} elseif { ([TCP::local_port] == 80) && ([string tolower HTTP::host]] equals "www.website.com") } {
HTTP::redirect https://[HTTP::host][HTTP::uri]
}
}
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
