Forum Discussion
Redirect Irule help
current irule for this app is as below. both test and test 2 resolves to 192.168.192.1=example.com when HTTP_REQUEST { if { [HTTP::uri] eq "/" } { HTTP::redirect https://[HTTP::host]/test } }
however if request comes to /test 2 should go to example.com/test2 and /test goes to examle.com/test.
will this works? Will below works?
when HTTP_REQUEST { if { [string tolower [HTTP::host]] eq "test" } { HTTP::redirect "https://example.com/[HTTP::uri]"
else
{ [string tolower [HTTP::host]] eq "test2" } { HTTP::redirect "https://example.com/[HTTP::uri]"
} }
thank you
- Samir_Jha_52506Noctilucent
Your iRule is correct. Please try this.
when HTTP_REQUEST { if { ( [string tolower [HTTP::uri]] starts_with "/test1" ) or ( [string tolower [HTTP::uri]] starts_with "/test2" ) } { HTTP::redirect "https://example.com[HTTP::uri]" }
}
- nitassEmployeei think forward slash (/) between fqdn and uri is not needed. HTTP::redirect "https://example.com[HTTP::uri]"
- KJ_50941Nimbostratus
Thank you both for responding. just to provide more info. both test and test2 are short names which resolves to 192.168.192.1. both are current forwarding to https://example.com/test, however we are trying to seperate them with irule, so request for test2 to route to https://exmaple.com/test2 while test should go to https://example.com/test
please if advice if above irules will work.
thx
- nitass_89166Noctilucent
e.g.
when HTTP_REQUEST { if { [HTTP::uri] equals "/" } { switch -glob [HTTP::host] { "*test1*" { HTTP::redirect "http://example.com/test1" } "*test2*" { HTTP::redirect "http://example.com/test2" } default { Host does not contain test1 or test2 Do something } } } else { URI is not root (/) Do something } }
- KJ_50941NimbostratusThank you, will test later on.
- nitassEmployee
e.g.
when HTTP_REQUEST { if { [HTTP::uri] equals "/" } { switch -glob [HTTP::host] { "*test1*" { HTTP::redirect "http://example.com/test1" } "*test2*" { HTTP::redirect "http://example.com/test2" } default { Host does not contain test1 or test2 Do something } } } else { URI is not root (/) Do something } }
- KJ_50941NimbostratusThank you, will test later on.
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