Forum Discussion
IRules mobile redirects help
I am stuck with particular type of redirects, what I need to do is ..
say a user request
abc.com/acd/dder/dr1-dc2-1245/ or http://abc.com/adv/dcb/34567/
from mobile device, so I want to take last portions numrics out
like 1245 in first URL and 34567 in second URL, and redirect it to something like site?gid=1245 or 34567
last digits are not limited with only 4 or 6 it can be abything, just numbers after - or after / .. I am unable to find out a way to do it ..
and if last digit is not numbers then just redirect to m.site.com
Please let me know if anyone can help out with it ..
Regards,
Ruchir
- hooleylistCirrostratusHi Ruchir,
- Ruchir_76829Nimbostratusthere can be many format, what we need to capture is digits from last and break point is either - or /
- hooleylistCirrostratusSo it's always the last subdirectory that you want to parse? And are the digits always on their own // or // or following a hyphen like this /AAA-AAA-AAA-/ or /AAA-AAA-AAA-/?
when HTTP_REQUEST { Get the index of the last URI directory set depth [URI::path [HTTP::uri] depth] Parse the last directory in the path set last_dir [URI::path [HTTP::uri] $depth $depth] Parse everything after the last hyphen in the last directory set digits [string trimleft [string range $last_dir [expr {[string last - $last_dir]}] end-1] -/] log local0. "URI=[HTTP::uri], \$depth=$depth, \$last_dir=$last_dir, \$digits=$digits" Check if we parsed 4 or 6 digits switch $digits { [0-9][0-9][0-9][0-9] - [0-9][0-9][0-9][0-9][0-9][0-9] { Found 4 or 6 digits, send a redirect HTTP::redirect "http://m.site.com/test/?gid=$digits" } } }
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