Forum Discussion
http redirect using iRule
Hello Guys,
This is my first query on iRule :)
**_My Requirement is : when some body access the http://abc.com/test/test.htm is should get redirected to new server & new URL which is http://pqr.com/test/test.htm._**
Note :1) abc.com website is public n locally published
2)website pqr.com is locally published.
Briefing :I want to redirect the user when they try to specifically access from below URI ( /test/test.htm) of the following URL
http://abc.com/test/test.htm the traffic should redirect to new Pool else
For other or any URI as below
http://abc.com/abc1/abc.htm http://abc.com//abc2.abc2.htm
it should go to old Pool
Please suggest if the following steps are correct -
VS = 192.168.1.x is mapped wih public ip on Firewall and published wtih ISP
1)Old Pool = abc-pool -- Remarks for all URI except /test - URI
2)New Pool = pqr-pool ---- Remarks only /test (URI)
Data group (example:Test- Redirect):
"/test" := "pqr-pool"
when HTTP_REQUEST { if { [class match [string tolower [HTTP::uri]] starts_with Test- Redirect] } { pool [class match -value [string tolower [HTTP::uri]] starts_with Test- Redirect] } else { pool abc-pool } }
3 Replies
- nitass
Employee
the irule looks fine for me.
when HTTP_REQUEST { if { [class match [string tolower [HTTP::uri]] starts_with Test-Redirect] } { pool [class match -value [string tolower [HTTP::uri]] starts_with Test-Redirect] } else { pool abc-pool } } - Kevin_Stewart
Employee
Your iRule looks correct.
when HTTP_REQUEST { if { [class match [string tolower [HTTP::uri]] starts_with Test-Redirect] } { pool [class match -value [string tolower [HTTP::uri]] starts_with Test-Redirect] } else { pool abc-pool } }** not sure if the space between "Test-" and "Redirect" was intentional, but there cannot be a space in the name. Otherwise, if it's as simple as a single URI check, you could probably skip the data group lookup.
when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/test" } { pool pqr-pool } else { pool abc-pool } }I'd also recommend applying a OneConnect profile here.
- Akber_157730
Nimbostratus
Hello Kevin,
Space in Data group (example:Test- Redirect): was a typo error and i will make sure
no space between when i implement the iRule.
Other than this is every thing seems ok in iRule for this requirement.
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