# Irule for lowercase

**URL:** <https://community.f5.com/t/irule-for-lowercase/5863>\
**Category:** Technical Forums\
**Tags:** irules, devops, ltm, application-delivery\
**Created:** [August 1, 2014, 1:01pm UTC](https://community.f5.com/t/irule-for-lowercase/5863 "2014-08-01T13:01:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vivek\_Padale\_16](https://avatars.discourse-cdn.com/v4/letter/v/e9bcb4/32.png) [@Vivek\_Padale\_16](https://community.f5.com/u/Vivek_Padale_16)\
**Post date:** [August 1, 2014, 1:01pm UTC](https://community.f5.com/t/irule-for-lowercase/5863/1 "2014-08-01T13:01:55Z")

</div>

Hello,

i want to create a irule for lowercase string for a specific url. Below is the irule which i am trying but i am not getting the result.The current version on client side is v11.3 .

when HTTP\_REQUEST { if {[string match {_[A-Z]_} [HTTP::uri] eq “[myBlock.Profile.com/Pages](http://myBlock.Profile.com/Pages)”]}{ HTTP::redirect “http://[HTTP::host][string tolower [HTTP::uri]]” } }

Thank you.

---

<div class="post-metadata">

**Author:** ![nathe](https://avatars.discourse-cdn.com/v4/letter/n/eb8c5e/32.png) [@nathe](https://community.f5.com/u/nathe)\
**Post date:** [August 1, 2014, 1:34pm UTC](https://community.f5.com/t/irule-for-lowercase/5863/2 "2014-08-01T13:34:10Z")

</div>

How about this?

```tcl
when HTTP_REQUEST {
 if {[string match {[A-Z]} [HTTP::uri] eq "myBlock.Profile.com/Pages"]}{ 
   set uri [string tolower [HTTP::uri]]
   HTTP::redirect "http://[HTTP::host]$uri" 
 }
}

```

Rgds

N

---

<div class="post-metadata">

**Author:** ![hoolio](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@hoolio](https://community.f5.com/u/hoolio)\
**Post date:** [August 1, 2014, 1:50pm UTC](https://community.f5.com/t/irule-for-lowercase/5863/3 "2014-08-01T13:50:59Z")

</div>

What are you trying to match with the first URI check? This expression doesn’t make sense to me:

```tcl
if {[string match {[A-Z]} [HTTP::uri] eq "myBlock.Profile.com/Pages"

```

Also, you need to use wildcards in the string match to check for any capital letter:

```tcl
% string match {[A-Z]} AAA
0
% string match {*[A-Z]*} AAA
1

```

So maybe something like this?

```tcl
when HTTP_REQUEST {
 if {"[HTTP::host][HTTP::uri]" eq "myBlock.Profile.com/Pages"]}{ 
   HTTP::redirect "myblock.profile.com/pages"
 }
}

```

Aaron

---

<div class="post-metadata">

**Author:** ![Vivek\_Padale\_16](https://avatars.discourse-cdn.com/v4/letter/v/e9bcb4/32.png) [@Vivek\_Padale\_16](https://community.f5.com/u/Vivek_Padale_16)\
**Post date:** [August 4, 2014, 8:41am UTC](https://community.f5.com/t/irule-for-lowercase/5863/4 "2014-08-04T08:41:16Z")

</div>

Hii,

The above irules are not working properly… So i tried something like this way…

when HTTP\_REQUEST { if {[HTTP::host] eq “[abfluat.abfsg.com](http://abfluat.abfsg.com)”]}{ HTTP::redirect “http://[HTTP::host][string tolower [HTTP::path]]?[HTTP::query]” } }

---

<div class="post-metadata">

**Author:** ![Vivek\_Padale\_16](https://avatars.discourse-cdn.com/v4/letter/v/e9bcb4/32.png) [@Vivek\_Padale\_16](https://community.f5.com/u/Vivek_Padale_16)\
**Post date:** [August 4, 2014, 8:41am UTC](https://community.f5.com/t/irule-for-lowercase/5863/5 "2014-08-04T08:41:40Z")

</div>

But this also not working properly…

---

<div class="post-metadata">

**Author:** ![nathe](https://avatars.discourse-cdn.com/v4/letter/n/eb8c5e/32.png) [@nathe](https://community.f5.com/u/nathe)\
**Post date:** [August 4, 2014, 8:54am UTC](https://community.f5.com/t/irule-for-lowercase/5863/6 "2014-08-04T08:54:38Z")

</div>

You’ve got an extra square brace on the 2nd line.

Also, http::path and http::query is, in effect, http::uri so why not try this?

```tcl
when HTTP_REQUEST { 
   if {[HTTP::host] eq "abfluat.abfsg.com"}{
     set uri [string tolower [HTTP::uri]]
     HTTP::redirect "http://[HTTP::host]$uri"
  } 
}

```

Rgds Nathan

---

<div class="post-metadata">

**Author:** ![nitass](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/nitass/32/2270_2.png) [@nitass](https://community.f5.com/u/nitass)\
**Post date:** [August 6, 2014, 2:52pm UTC](https://community.f5.com/t/irule-for-lowercase/5863/7 "2014-08-06T14:52:01Z")

</div>

what about this one?

```tcl
config

root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual bar
ltm virtual bar {
    destination 172.28.24.10:0
    ip-protocol tcp
    mask 255.255.255.255
    pool foo
    profiles {
        http { }
        tcp { }
    }
    rules {
        qux
    }
    source 0.0.0.0/0
    source-address-translation {
        type automap
    }
    translate-port disabled
    vs-index 60
}
root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule qux
ltm rule qux {
    when RULE_INIT {
  set static::uri "/myBlock.Profile.com/Pages"
  set static::uri_lower [string tolower $static::uri]
}
when HTTP_REQUEST {
  set uri [HTTP::uri]
  set uri_lower [string tolower $uri]
  if { $uri_lower eq $static::uri_lower } {
    if { $uri ne $uri_lower } {
      HTTP::redirect "http://[HTTP::host]$uri_lower"
    }
  }
}
}

 test

[root@ve11a:Active:In Sync] config curl -I http://172.28.24.10/myBlock.Profile.com/Pages
HTTP/1.0 302 Found
Location: http://172.28.24.10/myblock.profile.com/pages
Server: BigIP
Connection: Keep-Alive
Content-Length: 0

[root@ve11a:Active:In Sync] config curl -I http://172.28.24.10/myblock.profile.com/pages
HTTP/1.1 404 Not Found
Date: Wed, 06 Aug 2014 14:38:41 GMT
Server: Apache/2.2.3 (CentOS)
Content-Type: text/html; charset=iso-8859-1

```

---

<div class="post-metadata">

**Author:** ![Vivek\_Padale\_16](https://avatars.discourse-cdn.com/v4/letter/v/e9bcb4/32.png) [@Vivek\_Padale\_16](https://community.f5.com/u/Vivek_Padale_16)\
**Post date:** [August 9, 2014, 10:25am UTC](https://community.f5.com/t/irule-for-lowercase/5863/8 "2014-08-09T10:25:11Z")

</div>

Hello Guys, thanks for all responses. I had come up with a irule which is working properly..

when HTTP\_REQUEST { if { [HTTP::host] equals “[www.joe.com](http://www.joe.com)” and [HTTP::uri] starts\_with “/net/myjoe” } { HTTP::redirect “http://[HTTP::host][string tolower [HTTP::uri]]” } }
