Forum Discussion
URL Rewrite iRule Help Requested
Hi All,
Would appreciate if someone help me in verifying the following iRule..
My Requirement is that I have 2 URLs which resolves to the same IP address, the rewrite should take effect based on the URL.
dms-pd.abc.com and dms-dev.abc.com resolves to IP address 1.2.3.4
- If domain/host is dms-pd.abc.com, then redirect to http://10.10.10.1:50005/sap/
- If domain/host is dms-dev.abc.com, then redirect to http://10.10.10.2:8000/sap/
iRule Created and needs verification:
rule vip-1.2.3.4-irule { when HTTP_REQUEST { if { [HTTP::uri] == "/" } { HTTP::redirect "http://[HTTP::host]/irj/portal" } elseif { [string tolower [HTTP::uri]] starts_with "/irj" or [string tolower [HTTP::uri]] starts_with "/webdynpro" or [string tolower [HTTP::uri]] starts_with "/rtmfCommunicator" } { pool pool-10.10.10.10-50000 } elseif { ([HTTP::host] equals "dms-pd.abc.com") and ([HTTP::uri] starts_with "/sap") } { pool pool-10.10.10.1-50005} elseif { [string tolower [HTTP::uri]] starts_with "/sap" } { pool pool-10.10.10.2-8000}
5 Replies
- nitass
Employee
what about this?
when HTTP_REQUEST { switch -glob [HTTP::path] { "/" { HTTP::redirect "http://[HTTP::host]/irj/portal" } "/sap*" { switch [HTTP::host] { "dms-pd.abc.com" { pool pool-10.10.10.1-50005 } "dms-dev.abc.com" { pool pool pool-10.10.10.2-8000 } default { do something } } } "/irj*" - "/webdynpro*" - "/rtmfCommunicator*" { pool pool-10.10.10.10-50000 } default { do something } } }- BaluV_160328
Nimbostratus
Thanks for your quick response.. However, what could be the action for the following function ? default { do something }
- nitass_89166
Noctilucent
what about this?
when HTTP_REQUEST { switch -glob [HTTP::path] { "/" { HTTP::redirect "http://[HTTP::host]/irj/portal" } "/sap*" { switch [HTTP::host] { "dms-pd.abc.com" { pool pool-10.10.10.1-50005 } "dms-dev.abc.com" { pool pool pool-10.10.10.2-8000 } default { do something } } } "/irj*" - "/webdynpro*" - "/rtmfCommunicator*" { pool pool-10.10.10.10-50000 } default { do something } } }- BaluV_160328
Nimbostratus
Thanks for your quick response.. However, what could be the action for the following function ? default { do something }
- nitass
Employee
what could be the action for the following function ?
i just put it in case you want to do something when request does not match defined patterns. you can also delete it.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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