Forum Discussion
Convert rule on Apache to iRule
Hi all, I have a customer using apache to load balancing, on this device, they have a rule
^/thongtin/([0-9]+)/(.*)/?$ /wps/portal/abc/newsdetails?newsId=$1 [L,PT]
Plz help me to change this rule to iRule. Tks all,
8 Replies
- Michael_Jenkins
Cirrostratus
My suggestion would be to check out the iRules 101 articles to help learn how best to build iRules, and then look at the tcl scan command to parse your URI (Regex can be costly on resources, so only use it when you need to).
From there, you should be able put together an iRule that meets your needs. Looks like your requirements are any URI that matches
needs to go to^/thongtin/([0-9]+)/(.*)/?$
, where/wps/portal/abc/newsdetails?newsId=$1
is what's found in the$1
part of the uri.[0-9]+If you have trouble writing the iRule, I can try to help you out.
- TSV_166665
Nimbostratus
hi Michael J, You are right about this URI. Please help me to write this iRule. Tks you,
- NhatMinh-TSV_18
Nimbostratus
hi Michael J, Could you help me to write this iRule.
- Michael_Jenkins
Cirrostratus
So, with regexp, you could use an expression like:
if {[regexp {^/thongtin/([0-9]+)/.*/?$} [string tolower [HTTP::uri]] match id]} { HTTP::redirect "/wps/portal/abc/newsdetails?newsId=$id" }I'll try to put together the
version later.scan - TSV_166665
Nimbostratus
When I use iRule
when HTTP_REQUEST
{if {[regexp {^/thongtin/([0-9]+)/(._)/?$} [string tolower [HTTP::uri]] match id]} HTTP::redirect "/wps/portal/abc/newsdetails?newsId=$id"}I received a error:
01070151:3: Rule [/Common/aBC] error: /Common/aBC:2: error: [missing a script after "if"][]- Michael_Jenkins
Cirrostratus
sorry. typo in my code. I updated it now if you want to try again. - TSV_166665
Nimbostratus
It's working. Thank Michael J very much. - Michael_Jenkins
Cirrostratus
Please mark the answer as the solution so others can see it's solved.
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