# BIG-IP : irule not matching uri as expected

**URL:** <https://community.f5.com/t/big-ip-irule-not-matching-uri-as-expected/18298>\
**Category:** Technical Forums\
**Tags:** design, irules, tcl, devops, ltm, application-delivery\
**Created:** [September 18, 2015, 2:41am UTC](https://community.f5.com/t/big-ip-irule-not-matching-uri-as-expected/18298 "2015-09-18T02:41:05Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![BaltoStar\_12467](https://avatars.discourse-cdn.com/v4/letter/b/df705f/32.png) [@BaltoStar\_12467](https://community.f5.com/u/BaltoStar_12467)\
**Post date:** [September 18, 2015, 2:41am UTC](https://community.f5.com/t/big-ip-irule-not-matching-uri-as-expected/18298/1 "2015-09-18T02:41:05Z")

</div>

F5 BIG-IP Virtual Edition v11.4.1 (Build 635.0) LTM on ESXi

This code is logging all requests - including those with uri “/404” :

```tcl
when HTTP_REQUEST {
  if {[HTTP::uri] != "/404"} {
    log local0. "uri = [HTTP::uri]"
  }
}

```

Where is my mistake ?

---

<div class="post-metadata">

**Author:** ![Sriram\_87174](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@Sriram\_87174](https://community.f5.com/u/Sriram_87174)\
**Post date:** [September 18, 2015, 3:03am UTC](https://community.f5.com/t/big-ip-irule-not-matching-uri-as-expected/18298/2 "2015-09-18T03:03:24Z")

</div>

Are you trying to log the 404 error in the response packet? try using when HTTP\_RESPONSE function and see if you can log 404 error.

---

<div class="post-metadata">

**Author:** ![arpydays](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@arpydays](https://community.f5.com/u/arpydays)\
**Post date:** [September 18, 2015, 3:15am UTC](https://community.f5.com/t/big-ip-irule-not-matching-uri-as-expected/18298/3 "2015-09-18T03:15:11Z")

</div>

does the logged /404 uri match exactly /404 as per your irule or does it start with or contain /404 i.e. /404/

cheers

---

<div class="post-metadata">

**Author:** ![BaltoStar\_12467](https://avatars.discourse-cdn.com/v4/letter/b/df705f/32.png) [@BaltoStar\_12467](https://community.f5.com/u/BaltoStar_12467)\
**Post date:** [September 18, 2015, 3:50am UTC](https://community.f5.com/t/big-ip-irule-not-matching-uri-as-expected/18298/4 "2015-09-18T03:50:23Z")

</div>

/404 is a uri not a response error

---

<div class="post-metadata">

**Author:** ![Sriram\_87174](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@Sriram\_87174](https://community.f5.com/u/Sriram_87174)\
**Post date:** [September 18, 2015, 4:53am UTC](https://community.f5.com/t/big-ip-irule-not-matching-uri-as-expected/18298/5 "2015-09-18T04:53:26Z")

</div>

You can try using HTTP::path instead of HTTP::uri when HTTP\_REQUEST { if {[HTTP::path] != “/404”} { log local0. “uri = [HTTP::uri]” } }

---

<div class="post-metadata">

**Author:** ![arpydays](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@arpydays](https://community.f5.com/u/arpydays)\
**Post date:** [September 18, 2015, 4:55am UTC](https://community.f5.com/t/big-ip-irule-not-matching-uri-as-expected/18298/6 "2015-09-18T04:55:57Z")

</div>

not sure what’s going on then - I’m using 11.6 VE, prehaps you can run the same commands and post your results

```tcl
ltm rule test404 {
  when HTTP_REQUEST {
    if {[HTTP::uri] != "/404"} {
      log local0. "uri = [HTTP::uri]"
    }
  }
}

[root@f5lab] config curl http://10.12.12.145/402
[root@f5lab] config curl http://10.12.12.145/403
[root@f5lab] config curl http://10.12.12.145/404
[root@f5lab] config curl http://10.12.12.145/405

Sep 18 16:43:00 f5lab info tmm[17994]: Rule /Common/test404 : uri = /402
Sep 18 16:43:05 f5lab info tmm[17994]: Rule /Common/test404 : uri = /403
Sep 18 16:43:11 f5lab info tmm[17994]: Rule /Common/test404 : uri = /405

```

---

<div class="post-metadata">

**Author:** ![Sriram\_87174](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@Sriram\_87174](https://community.f5.com/u/Sriram_87174)\
**Post date:** [September 18, 2015, 5:21am UTC](https://community.f5.com/t/big-ip-irule-not-matching-uri-as-expected/18298/7 "2015-09-18T05:21:36Z")

</div>

I tried with both HTTP::path and HTTP::uri - It works fine. i am using v11.4.1 BIG-IP appliance.

---

<div class="post-metadata">

**Author:** ![BaltoStar\_12467](https://avatars.discourse-cdn.com/v4/letter/b/df705f/32.png) [@BaltoStar\_12467](https://community.f5.com/u/BaltoStar_12467)\
**Post date:** [September 18, 2015, 5:26am UTC](https://community.f5.com/t/big-ip-irule-not-matching-uri-as-expected/18298/8 "2015-09-18T05:26:07Z")

</div>

/404 is the entire uri ( no query-params ) so aren’t [HTTP::path] and [HTTP::uri] equivalent ?

---

<div class="post-metadata">

**Author:** ![Sriram\_87174](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@Sriram\_87174](https://community.f5.com/u/Sriram_87174)\
**Post date:** [September 18, 2015, 5:32am UTC](https://community.f5.com/t/big-ip-irule-not-matching-uri-as-expected/18298/9 "2015-09-18T05:32:17Z")

</div>

Agree, Yes that is correct you could use either. log the full uri when the request comes in before it goes to the if statement. To verify it is exactly what you expect it to be and then work out why it doesnt not match the expression for /404 ?

---

<div class="post-metadata">

**Author:** ![Robert\_Luechte2](https://avatars.discourse-cdn.com/v4/letter/r/8dc957/32.png) [@Robert\_Luechte2](https://community.f5.com/u/Robert_Luechte2)\
**Post date:** [September 18, 2015, 6:48pm UTC](https://community.f5.com/t/big-ip-irule-not-matching-uri-as-expected/18298/10 "2015-09-18T18:48:51Z")

</div>

Try using ne instead of !=. You may be having an issue with data type conversion. Using ne will ensure you are doing a string comparison. I’m not positive that is the issue, but it’s an easy change to test.
