Forum Discussion
need help to get uri to work regardless of any extra characters
I have an irule that uses a data class to look for a keyword and if found redirects to another URL.
This part works fine but if for some reason any extra characters are put into the URL it fails.
For instance https://www.someplace.com/test would redirect to https://www.someotherplace.com
But if for any reason someone types in testy or anything besides /testyingiti etc it fails.
I've tried using starts_with but no dice. Would anyone know a method to redirect IF any part of test is in the word?
Thanks for any assistance.
- What_Lies_Bene1
Cirrostratus
Try 'contains' - nitass
Employee
I've tried using starts_with but no dice. just wondering why starts_with did not work. anyway, contains which Beneath suggested should work. - pmaubo2_55685
Nimbostratus
I confirmed "starts_with" in my irule calling a uri from a data class was working if any other characters were added, it just did not work correctly and/or broke with no redirect. Why? I really am at a loss. "Contains" also does not work, so it must be the nature of how the irule was written. Below is the key ingrediants so anyone can spot something, have at it. - nitass
Employee
what about this one?[root@ve10:Active] config b virtual bar list virtual bar { snat automap pool foo destination 172.28.19.79:443 ip protocol 6 rules myrule profiles { clientssl { clientside } http {} tcp {} } } [root@ve10:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { set my_uri [string tolower [HTTP::uri]] if {[class match -- $my_uri contains www_vanity_url_redirection]} { set vanity_path [class match -value $my_uri contains www_vanity_url_redirection] HTTP::redirect $vanity_path } } } [root@ve10:Active] config b class www_vanity_url_redirection list class www_vanity_url_redirection { "/test" { "https://www.someotherplace.com" } } [root@ve10:Active] config curl -Ik https://172.28.19.79/test HTTP/1.0 302 Found Location: https://www.someotherplace.com Server: BigIP Connection: Keep-Alive Content-Length: 0 [root@ve10:Active] config curl -Ik https://172.28.19.79/testy HTTP/1.0 302 Found Location: https://www.someotherplace.com Server: BigIP Connection: Keep-Alive Content-Length: 0
- pmaubo2_55685
Nimbostratus
YES!!!! I really appreciate your input and help! Even several other experienced F5 people I knew could not figure this one out! - pmaubo2_55685
Nimbostratus
There is one issue that remains. There is a potion above this irule that detects a mobile phone and if it finds it in our Data Class it will use anothere Data Class for keywords and then redirect to our mobile site, so it will recieve optimized pages. - nitass
Employee
set mobile_uri [class search -value mobile_phone_optimized_uri eq [string tolower $my_uri]]
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