Forum Discussion
Nedd help with https redirect
Hello Guys,
I need help with iRule.. I have created specific ip for redirection for my web site from http to https (even if contain IP).
Here what I did
when HTTP_REQUEST { if { [HTTP::host] contains "xyz.com" or "10.x.x.x" or "1x.x.x.x" } { HTTP::redirect https://www.xyz.com } }
When user send request to http://xyz.com redirection works fine. But if user try https://xyz.com/test (or anything after /) it’s redirecting back to https://www,xyz.com home page.
Is there a way to define rule so redirect with requested url ?
Thanks, GSingh
5 Replies
- shaggy
Nimbostratus
when HTTP_REQUEST { if { [HTTP::host] contains "xyz.com" or "10.x.x.x" or "1x.x.x.x" } { HTTP::redirect https://www.xyz.com[HTTP::uri] } }
- Gurinder_Singh_
Nimbostratus
Thanks Shaggy..but it's still redirecting back to home page.
here is what is did
when HTTP_REQUEST { if { [HTTP::host] contains "xyz.com" or "10.x.x.x" or "1x.x.x.x" } { HTTP::redirect https://www.xyz.com[HTTP::uri] } }
let me know if i am doing it right?
Thanks, GSingh
- shaggy
Nimbostratus
The redirect portion looks correct, but the if statement looks off: if { [HTTP::host] contains "xyz.com" or [HTTP::host] contains "10.x.x.x" or [HTTP::host] contains "1x.x.x.x" }
- Gurinder_Singh_
Nimbostratus
Fix the statement, But still no luck .. redirecting back home page (https://www.xyz.com)
when HTTP_REQUEST { if { [HTTP::host] contains "xyz.com" or [HTTP::host] contains "10.x.x.x" or [HTTP::host] contains "1x.x.x.x" } { HTTP::redirect https://www.xyz.com[HTTP::uri] } }
- shaggy
Nimbostratus
Is a subsequent redirect coming from the server? I use this syntax often in iRules and have no issues (see the _sys_https_redirect iRule for an example of an f5-supplied iRule using the syntax). Have you tried testing from curl or another client that will show you exactly what is coming back from the F5?
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