Forum Discussion
Irule Redirection Problems
on one virtual server need publish 3 sites; site A ( this site is on IIS and i need redirect request to this site subdirectory); site B ; site C ;
This is my irules
when HTTP_REQUEST priority 10 { if { ([HTTP::host] equals "SiteA.com") and ([HTTP::uri] ends_with "/") } { HTTP::redirect "; } }
when HTTP_REQUEST priority 20 { switch [string tolower [HTTP::host]] { "SiteB.com" { pool B } "SiteC.com" { pool C } } }
question 1. why ssl Offloading not woriking For SiteA.com ? 2. why i see in browser "; and not http://siteA.com/subdirectory
Site B and Site C working ok
Hi,
I would recommend first combining all of the logic into one event. Your example switch statement used the "string tolower" function but the matching values were capitialized. You may also consider adding a default section if you have some other condition to match.
when HTTP_REQUEST { switch [string tolower [HTTP::host]] { "sitea.com" { if { [HTTP::uri] ends_with "/" } { HTTP::redirect "http://192.168.0.0/subdirectory" } } "siteb.com" { pool B } "sitec.com" { pool C } } }
If you are testing an iRule but it won't load, check the /var/log/ltm log file to see if any runtime error messages are logged.
Hope this helps.
-Josh
- youssef1
Cumulonimbus
Hi,
can you try this irule:
when HTTP_REQUEST priority { switch [string tolower [HTTP::host]] { "SiteA.com" { if { [HTTP::uri] == "/" } { HTTP::redirect "https://SiteA.com/subdirectory" } SSL::disable serverside pool A } "SiteB.com" { pool B } "SiteC.com" { pool C } } }
As you can noticed, I disable ssl server on site A side, Can you confirm that poolmember in pool A don't listen in 443 (TLS).
Second point In your VS don't forget to
. is important it will allow you to do a per request decision for forwardin to the right pool.set a oneconnect profil
Last point i modified the condition for Site A, I set
instead[HTTP::uri] == "/"
, I think that it's more logical and is what you want to do!!![HTTP::uri] ends_with "/"
last point let me know if you see again in your browser ";; and not http://siteA.com/subdirectory. In this case we will need to set a rewrite the location header.
keep me update.
- Stanislas_Piro2
Cumulonimbus
why i see in browser ";; and not http://siteA.com/subdirectory
means the f5 send a response to the browser to go to this url...HTTP::redirect "http://192.168.0.0/subdirectory"
Youssef solution may solve your issue, except the redirect which may be
HTTP::redirect "/subdirectory"
Youssef’s solution works but is not optimal.
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