# Need help with irule

**URL:** <https://community.f5.com/t/need-help-with-irule/70572>\
**Category:** Technical Forums\
**Tags:** application-delivery\
**Created:** [September 20, 2022, 2:39pm UTC](https://community.f5.com/t/need-help-with-irule/70572 "2022-09-20T14:39:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vishnu1994](https://avatars.discourse-cdn.com/v4/letter/v/df788c/32.png) [@vishnu1994](https://community.f5.com/u/vishnu1994)\
**Post date:** [September 20, 2022, 2:39pm UTC](https://community.f5.com/t/need-help-with-irule/70572/1 "2022-09-20T14:39:18Z")

</div>

Hi&nbsp;  
I have an application [xyz.com](http://xyz.com) and we need only certain URI to be accessable and if the user directly go to [xyz.com](http://xyz.com) they need to get URL NOT ACCESSIBLE &nbsp;and users only allowed to go to [.xyz Domain Names | Join Generation XYZ](http://xyz.com/page1) ; [.xyz Domain Names | Join Generation XYZ](http://xyz.com/page2)

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

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Kevin\_Stewart](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_stewart/32/15267_2.png) [@Kevin\_Stewart](https://community.f5.com/u/Kevin_Stewart)\
**Post date:** [September 20, 2022, 3:29pm UTC](https://community.f5.com/t/need-help-with-irule/70572/2 "2022-09-20T15:29:40Z")

</div>

A simple switch might look like this:

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

```

---

<div class="post-metadata">

**Author:** ![vishnu1994](https://avatars.discourse-cdn.com/v4/letter/v/df788c/32.png) [@vishnu1994](https://community.f5.com/u/vishnu1994)\
**Post date:** [September 21, 2022, 4:53pm UTC](https://community.f5.com/t/need-help-with-irule/70572/3 "2022-09-21T16:53:05Z")

</div>

Hello&nbsp;  
This I rule is blocking the URL’s/URI’s even with the /page1 and /page2

any suggestion?

---

<div class="post-metadata">

**Author:** ![vishnu1994](https://avatars.discourse-cdn.com/v4/letter/v/df788c/32.png) [@vishnu1994](https://community.f5.com/u/vishnu1994)\
**Post date:** [September 21, 2022, 4:54pm UTC](https://community.f5.com/t/need-help-with-irule/70572/4 "2022-09-21T16:54:57Z")

</div>

Hello&nbsp;  
This I rule is blocking the URI’s even with the /page1 and /page2

---

<div class="post-metadata">

**Author:** ![Kevin\_Stewart](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_stewart/32/15267_2.png) [@Kevin\_Stewart](https://community.f5.com/u/Kevin_Stewart)\
**Post date:** [September 21, 2022, 7:26pm UTC](https://community.f5.com/t/need-help-with-irule/70572/5 "2022-09-21T19:26:44Z")

</div>

Try with some verbose logging:

```tcl
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"
      }
   }
}

```
