Forum Discussion
redirect to https multiple uri's while letting others pass through
I have created a Virtual Server with port 80, created a pool and have added the iRule to the Virtual server. I have a wild card SSL cert that works for our appsf5.com
I have created the following iRule, but it only works once or twice before getting a page not found.
when HTTP_REQUEST
{ if { [HTTP::host] equals "appsf5.com" }{
if { [HTTP::uri] starts_with "/applications/app1" }
{ HTTP::redirect "https://[HTTP::host]/applications/app1/logon.aspx" }
elseif { [HTTP::uri] starts_with "/applications/app2" }
{ HTTP::redirect "https://[HTTP::host]/applications/app2/login.asp" }
elseif { [HTTP::uri] starts_with "/applications/app3" }
{ HTTP::redirect "https://[HTTP::host]/applications/app3/login.asp" }
elseif { [HTTP::uri] starts_with "/applications/app4" }
{ HTTP::redirect "https://[HTTP::host][HTTP::uri]" }
else {HTTP::respond "http://[HTTP::host][HTTP::uri]" }
}
}
- The_BhattmanNimbostratusHi Deni,
- deni_22991NimbostratusI'm sorry, we actually used HTTP:Request. And we were able to make it consistently working by adding a host header to account for the IP being used for the VS for port 80 and 443.
- deni_22991NimbostratusWell, we thought we had it working. This is what the iRule actually says
- Colin_Walker_12Historic F5 AccountSo you're looking to redirect based on the URI ? Something like this perhaps?
when HTTP_REQUEST { if { [HTTP::host] equals "appsf5.com" } { switch [string tolower [HTTP::uri]] { "/applications/app1*" { HTTP::redirect "https://[HTTP::host]/applications/app1/logon.aspx" } "/applications/app2*" { HTTP::redirect "https://[HTTP::host]/applications/app2/login.asp" } "/applications/app3*" { HTTP::redirect "https://[HTTP::host]/applications/app3/login.asp" } "/applications/app4*" { HTTP::redirect "https://[HTTP::host][HTTP::uri]" } } } }
- deni_22991Nimbostratus
If we only put in the redirects to https: the applications that are not https display a page cannot be displayed error. So yes, we are trying to do a redirect based on URI for those applications that need to be https and let those that are http: just be ignored by the iRule.
- Chris_MillerAltostratusPosted By deni on 01/05/2011 11:15 AM
If we only put in the redirects to https: the applications that are not https display a page cannot be displayed error. So yes, we are trying to do a redirect based on URI for those applications that need to be https and let those that are http: just be ignored by the iRule.
- deni_22991NimbostratusThat is what I am looking for. I have applied this rule. At the moment it is working. But I will test again in an hour or so. We have had the rule work one time and the next time we tested, only half worked and another time none worked.
- deni_22991NimbostratusThe rule does not work as expected. If I use https://appsf5.com/applications/app1/logon.asp it does work. If I try http://appsf5.com/applications/app1/logon.asp, it does not redirect me to the https address.
- Chris_MillerAltostratusPosted By deni on 01/06/2011 08:21 AM
- deni_22991NimbostratusIt is applied only on the Virtual Server listening on port 80.
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