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...
Chris_Miller
Altostratus
Sep 22, 2010There are two main parts to a common url like "http://website.com."
1. [HTTP::host] is "website.com"
2. [HTTP::uri] is typically "/" for a home page, it's basically the part after the host and before queries, paths, etc.
In your case, you're looking for a URI to equal "website.com" which will never happen. Also, by using HTTP::uri on the line after, you're essentially rewriting the URI on the way to your pool member. The reason you were redirected to https://website.com is because you met your else statement.
Try this:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] eq "website.com"} {
HTTP::redirect "https://[HTTP::host][HTTP::uri]" } }
Instead of "eq", you could also use "starts_with" as some clients/browsers will send you hosts like "website.com."
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
