Forum Discussion
nassahla_65866
Nimbostratus
May 29, 2010I Rule Help
Hello all, i am trying to come up with an irule that will help us accomplish the following, a redirect from http to https, and additionally i also need to have a redirect on a url for example https://abc.com/123 being redirected to https://abc.com/123/login.do inorder words i dont want my the client having to type /login.do when they access the site. Here is an attempt on my part my on i my on the right track....thanks in advance...
when {HTTP::request {
if { ([HTTP::host] eq "abc.com") && (HTTP::uri] eq"/123/" } {
HTTP::redirect "https://abc.com/123/login.do
}
}
9 Replies
- The_Bhattman
Nimbostratus
Hi Nassahla,
Assuming that you have 2 virtuals (http and https)
Here is an irule for HTTPwhen HTTP_REQUEST { HTTP::redirect "https://[HTTP::host]/[HTTP::uri]" }
For the HTTPS virtualwhen HTTP_REQUEST { if { ([HTTP::host] eq "abc.com") and ([HTTP::uri] eq "/123") } { HTTP::redirect "https://[HTTP::host]/[HTTP::uri]/login.do" } }
Please keep in mind that the HTTPS to HTTPS redirect will work if the SSL is terminated on the F5 and not on the web server itself.
I hope this helps
Bhattman - The_Bhattman
Nimbostratus
Hi Nassahla,
Assuming that you have 2 virtuals (http and https)
Here is an irule for HTTPwhen HTTP_REQUEST { HTTP::redirect "https://[HTTP::host]/[HTTP::uri]" }
For the HTTPS virtualwhen HTTP_REQUEST { if { ([HTTP::host] eq "abc.com") and ([HTTP::uri] eq "/123") } { HTTP::redirect "https://[HTTP::host]/[HTTP::uri]/login.do" } }
Please keep in mind that the HTTPS to HTTPS redirect will work if the SSL is terminated on the F5 and not on the web server itself.
I hope this helps
Bhattman - The_Bhattman
Nimbostratus
Hi Nassahla,
Assuming that you have 2 virtuals (http and https)
Here is an irule for HTTPwhen HTTP_REQUEST { HTTP::redirect "https://[HTTP::host]/[HTTP::uri]" }
For the HTTPS virtualwhen HTTP_REQUEST { if { ([HTTP::host] eq "abc.com") and ([HTTP::uri] eq "/123") } { HTTP::redirect "https://[HTTP::host]/[HTTP::uri]/login.do" } }
Please keep in mind that the HTTPS to HTTPS redirect will work if the SSL is terminated on the F5 and not on the web server itself.
I hope this helps
Bhattman - nassahla_65866
Nimbostratus
Thanks Bhatman, is it imperative to have 2 virtuals one configured for an http and the other for https or can i just have use the one i have already which is configured for https then do the redirect based on that .. ? - The_Bhattman
Nimbostratus
Hi Nassahla,
In order for the HTTP to HTTPS redirect to work you would need a virtual that would accept requests on PORT 80.
If you have 2 virtuals you can certainly handle both http to https and HTTPS to HTTPS.
However, you can also do the same thing on a single virtual.
Here is link to that particular irule
http://devcentral.f5.com/wiki/default.aspx/iRules/HttpHttpsSingleVirtualServer.html
Bhattman - nassahla_65866
Nimbostratus
Hello all- i try putting the following in an i-rule editor then checking the syntax, it seems to be throwing errors at me what i my missing here ?... or is it ok to ignore the i-rule editor forcing about the syntax i am getting it on line all 3 lines...
when HTTP_REQUEST {
if{[HTTP::host]eq"xxx.com")and([HTTP::uri] eq"/xxx")
HTTP::redirect "https://[http::host]/[HTTP::uri]/login.do" - The_Bhattman
Nimbostratus
I believe you are missing some braceswhen HTTP_REQUEST { If { match something.... } { Do something... } }
I hope this helps
Bhattman - L4L7_53191
Nimbostratus
If the rule you've pasted above is the actual rule, you're missing some curly brackets and an open parenthesis. Also watch your cases - iRules are case sensitive (http::host isn't valid, but HTTP::host is). It should look something like this:when HTTP_REQUEST { if { ([HTTP::host] eq "xxx.com") and ([HTTP::uri] eq "/xxx") } { HTTP::redirect "https://[HTTP::host]/[HTTP::uri]/login.do" } }
I've not tested the above rule, but it should go on clean.
-Matt - nassahla_65866
Nimbostratus
sweet thanks for the pointers...
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
