Forum Discussion
Redirect issue (Global http to https but one website)
Hello everyone,
My goal was to redirect everything to https but one website. This website has to stay on http.
I have with some looking around and working up created the following code:
when HTTP_REQUEST {
switch [string tolower [HTTP::host][HTTP::uri]] {
"http://www.abc.com/xyz/def"
{
return
do nothing
}
default {
HTTP::respond 302 location "https://[HTTP::host][HTTP::uri]"
event disable
TCP::close
}
}
}The issue I have is that www.abc.com/xyz/def is suffering from "Too many redirects loop" is this due to the code being erroneous? This is the only iRule currently attached to the virtual server.
Any help would be appreciated and thank you in advance!
8 Replies
- Brad_Parker_139
Nacreous
Take the http:// part out of your first switch conditional. also you may want to use the glob parameter in the switch. IE switch -glob then make your condition end with a * since I assume you may have some longer paths and possible query parameters. HTTTP::uri includes query parameters.
- Lucilius_223799
Nimbostratus
Thank you for the answer Brad, I changed the iRule with your recommendations. However the pages that shouldn't be redirected to https are still going to https from what I can see and are stuck in an a redirect loop. I wonder if it is something on the other side that is causing that issue though and not the iRule itself. - Please post your changed iRule, so that we can find the incorrect parts... ;-)
- Brad_Parker_139
Nacreous
Lets take one step back and see if we even need an irule. Where is this iRule attached? You say one website needs to not redirect to HTTPS. is that a whole FQDN or just the application pathh you specified in your sample irule?
- Brad_Parker
Cirrus
Take the http:// part out of your first switch conditional. also you may want to use the glob parameter in the switch. IE switch -glob then make your condition end with a * since I assume you may have some longer paths and possible query parameters. HTTTP::uri includes query parameters.
- Lucilius_223799
Nimbostratus
Thank you for the answer Brad, I changed the iRule with your recommendations. However the pages that shouldn't be redirected to https are still going to https from what I can see and are stuck in an a redirect loop. I wonder if it is something on the other side that is causing that issue though and not the iRule itself. - Please post your changed iRule, so that we can find the incorrect parts... ;-)
- Brad_Parker
Cirrus
Lets take one step back and see if we even need an irule. Where is this iRule attached? You say one website needs to not redirect to HTTPS. is that a whole FQDN or just the application pathh you specified in your sample irule?
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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