Forum Discussion
VijayKumarBC_25
Nimbostratus
May 20, 2016HTTPS to HTTP Redirection changes required
Below redirection iRule is working for - https://www.my.com
But Not working for https://my.com
Please suggest if there are any changes required
when HTTP_REQUEST {
set HOST [string tolow...
VernonWells
Employee
May 20, 2016That rule should work fine. I suggest adding logging. In addition, is there more to the iRule? If not, I recommend strongly against setting
$URI. In fact, it's sub-optimal to set $HOST as a variable, unless it is going to be used more than once. Normally, in programming, coding defensively and optimizing for readability and maintenance efficiency is sensible, but that's not the case with iRules. If one must choose between those things and performance, you almost always want to choose performance, since it executes with each connection (or, in the case of the rule below, each HTTP Request received). Finally, the use of -glob on the switch should be used only if you intend to perform glob matching. For strict matching, it's about 10% faster to exclude the -glob. Perhaps give this a try:
when HTTP_REQUEST {
switch [string tolower [HTTP::host]] {
"my.com" -
"www.my.com" {
log local0. "Matched HTTP::host = [HTTP::host]"
HTTP::respond 301 Location "http://www.my.com"
}
}
Look in
/var/log/ltm for the log message. If it does not match when you are going to https://my.com, then try the following:
when HTTP_REQUEST {
log local0. "Host header = [string tolower [HTTP::host]]"
switch [string tolower [HTTP::host]] {
"my.com" -
"www.my.com" {
HTTP::respond 301 Location "http://www.my.com"
}
}
and try the request, again looking in
/var/log/ltm (be aware that, if the request rate is quite high, the log may be suppressed, and you may end up with a lot of logging!). Once you are done testing, don't forget to remove the logging statements, of course.Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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