Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with irule

vishnu1994
Altostratus
Altostratus

Hi 
I have an application xyz.com and we need only certain URI to be accessable and if the user directly go to xyz.com they need to get URL NOT ACCESSIBLE  and users only allowed to go to xyz.com/page1 ; xyz.com/page2 

How can we write a irule to allow this type of request?

Thanks in advance.

1 ACCEPTED SOLUTION

Kevin_Stewart
F5 Employee
F5 Employee

A simple switch might look like this:

when HTTP_REQUEST {
   switch -glob [string tolower [HTTP::uri]] {
      "/page1" -
      "/page2" { }
      default {
          HTTP::respond 400 content "URL NOT ACCESSIBLE" "Connection" "close"
      }
   }
}

View solution in original post

4 REPLIES 4

Kevin_Stewart
F5 Employee
F5 Employee

A simple switch might look like this:

when HTTP_REQUEST {
   switch -glob [string tolower [HTTP::uri]] {
      "/page1" -
      "/page2" { }
      default {
          HTTP::respond 400 content "URL NOT ACCESSIBLE" "Connection" "close"
      }
   }
}

Hello 
This I rule is blocking the URI's even with the /page1 and /page2

vishnu1994
Altostratus
Altostratus

Hello 
This I rule is blocking the URL's/URI's even with the /page1 and /page2

any suggestion? 

Try with some verbose logging:

when HTTP_REQUEST {
   log local0. "Here: [string tolower [HTTP::uri]]"
   switch -glob [string tolower [HTTP::uri]] {
      "/page1/*" -
      "/page2/*" { 
          log local0. "Matching page1/page2, allow to pass through"
      }
      default {
          log local0. "Not matching page1/page2, block"
          HTTP::respond 400 content "URL NOT ACCESSIBLE" "Connection" "close"
      }
   }
}