Forum Discussion
irule to allow specific url
Hi,
I am trying to allow only specific path of an URI and got this code from devcentral but its giving lot of errors
when HTTP_REQUEST { switch -glob [string tolower [HTTP::path]] { switch -glob [HTTP::path] { "/KURservlet/servlet/KURServlet" - "/KURservlet-stage/servlet/KURServlet" - "/KURservlet-test/servlet/KURServlet*" {} default { HTTP::redirect noserver "https://Ind-hyd.vidya.com/error/invalid.html } } }
Can someone help me in allowing only specific paths using URI.
6 Replies
- Nuruddin_Ahmed_
Cirrostratus
i get below errors 01070151:3: Rule [/Common/Specific-URL-erp-qas] error: /Common/Specific-URL-erp-qas:1: error: [parse error: missing close-brace: possible unbalanced brace in comment][{ switch -glob [string tolower [HTTP::path]] { switch -glob [HTTP::path] { "/KURservlet/servlet/KURServlet*" - "/KURservlet-stage/servlet/KURServlet*" - "/KURservlet-test/servlet/KURServlet*" {} default { HTTP::redirect noserver "https://Ind-hyd.vidya.com/error/invalid.html } } }] /Common/Specific-URL-erp-qas:3: error: [command is not valid in the current scope][switch -glob [HTTP::path] { "/KURservlet/servlet/KURServlet*" - "/KURservlet-stage/servlet/KURServlet*" - "/KURservlet-test/servlet/KURServlet*" {} default { HTTP::redirect noserver "https://Ind-hyd.vidya.com/error/invalid.html } }] /Common/Specific-URL-erp-qas:3: error: [command is not valid in the current scope][HTTP::path] /Common/Specific-URL-erp-qas:9: error: [command is not valid in the current scope] Hi,
Find below a working irule :
when HTTP_REQUEST { switch -glob [HTTP::path] { "/KURservlet/servlet/KURServlet" - "/KURservlet-stage/servlet/KURServlet" - "/KURservlet-test/servlet/KURServlet*" {} default { HTTP::redirect noserver "https://Ind-hyd.vidya.com/error/invalid.html } } } }- Nuruddin_Ahmed_
Cirrostratus
Hi Yann, Thanks for quick and as always the right reply :) i want to achieve one more thing here...lower the path string but i am getting the error in compling the rule when i try that.
- Yann_Desmarest_
Nacreous
Hi,
Find below a working irule :
when HTTP_REQUEST { switch -glob [HTTP::path] { "/KURservlet/servlet/KURServlet" - "/KURservlet-stage/servlet/KURServlet" - "/KURservlet-test/servlet/KURServlet*" {} default { HTTP::redirect noserver "https://Ind-hyd.vidya.com/error/invalid.html } } } }- Nuruddin_Ahmed_
Cirrostratus
Hi Yann, Thanks for quick and as always the right reply :) i want to achieve one more thing here...lower the path string but i am getting the error in compling the rule when i try that.
Hi,
Find below the code to have lower case. Notice that you need to set every path to lower case under the switch condition :
when HTTP_REQUEST { switch -glob [string tolower [HTTP::path]] { "/kurservlet/servlet/kurservlet" - "/kurservlet-stage/servlet/kurservlet" - "/kurservlet-test/servlet/kurservlet*" {} default { HTTP::redirect noserver "https://Ind-hyd.vidya.com/error/invalid.html } } } }
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