Forum Discussion
Applying lowercase iRule to HTTPS virtual server?
Ok, looks like I have a working solution now.
Thanks Stanislas - it's basically your rule blended into with my existing redirection rule.
So the lowercasing happens as planned, but also every HTTP/HTTPS/WWW/non-WWW combination still gets detected and 301 redirected too.
Just tested all 10 possible combinations for a page and all good so far.
- mysitename.com/page (without HTTP/HTTPS/WWW) --> 301 redirect --> https://www.mysitename.com/page
- mysitename.com/PAGE (without HTTP/HTTPS/WWW) --> 301 redirect --> https://www.mysitename.com/page
- http://mysitename.com/page --> 301 redirect --> https://www.mysitename.com/page
- http://mysitename.com/PAGE --> 301 redirect --> https://www.mysitename.com/page
- http://www.mysitename.com/page --> 301 redirect --> https://www.mysitename.com/page
- http://www.mysitename.com/PAGE --> 301 redirect --> https://www.mysitename.com/page
- https://mysitename.com/page --> 301 redirect --> https://www.mysitename.com/page
- https://mysitename.com/PAGE --> 301 redirect --> https://www.mysitename.com/page
- https://www.mysitename.com/page --> HTTP/200 --> https://www.mysitename.com/page
- https://www.mysitename.com/PAGE --> 301 redirect --> https://www.mysitename.com/page
Working iRule 1
when HTTP_REQUEST {
if {[string tolower [HTTP::host]] starts_with "www.mysitename.com" && [string match {*[A-Z]*} [HTTP::uri]]}{
HTTP::respond 301 noserver Location "https://www.mysitename.com[string tolower [HTTP::uri]]"
} elseif
{[string tolower [HTTP::host]] starts_with "mysitename.com" && [string match {*[A-Z]*} [HTTP::uri]]}{
HTTP::respond 301 noserver Location "https://www.mysitename.com[string tolower [HTTP::uri]]"
} elseif
{[string tolower [HTTP::host]] starts_with "mysitename.com" } {
HTTP::respond 301 noserver Location "https://www.mysitename.com[string tolower [HTTP::uri]]"
}
}
I'm going to continue to test, but looks good so far.
If anyone can see any ways that I can optimize this rule and trim some fat off it, please let me know.
Thanks for everyone's input on this post... much appreciated.
Recent Discussions
Related Content
* 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