# Adding a URI using IRULE

**URL:** <https://community.f5.com/t/adding-a-uri-using-irule/21000>\
**Category:** Technical Forums\
**Tags:** irules, application-delivery\
**Created:** [August 23, 2018, 1:21pm UTC](https://community.f5.com/t/adding-a-uri-using-irule/21000 "2018-08-23T13:21:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sukesh123456\_25](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@Sukesh123456\_25](https://community.f5.com/u/Sukesh123456_25)\
**Post date:** [August 23, 2018, 1:21pm UTC](https://community.f5.com/t/adding-a-uri-using-irule/21000/1 "2018-08-23T13:21:56Z")

</div>

I want to add a URI using an irule. I saw different articles but could not find any one exactly matching my requirement.

Below is the requirement.

When I hit a VIP it should add a URI at the end. For example,

\> **/prl-ws//**

Any help would be really appreciated.

Thanks!

---

<div class="post-metadata">

**Author:** ![Joseph\_Lindsly](https://avatars.discourse-cdn.com/v4/letter/j/8c91f0/32.png) [@Joseph\_Lindsly](https://community.f5.com/u/Joseph_Lindsly)\
**Post date:** [August 23, 2018, 1:27pm UTC](https://community.f5.com/t/adding-a-uri-using-irule/21000/2 "2018-08-23T13:27:32Z")

</div>

Try this:

```tcl
when HTTP_REQUEST {
if { [HTTP::uri] equals "/"}
 {
    HTTP::redirect "https://[HTTP::host]/prl-ws//"
 }
}

```

---

<div class="post-metadata">

**Author:** ![stan\_piron](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@stan\_piron](https://community.f5.com/u/stan_piron)\
**Post date:** [August 23, 2018, 2:27pm UTC](https://community.f5.com/t/adding-a-uri-using-irule/21000/3 "2018-08-23T14:27:05Z")

</div>

Do you want to redirect (HTTP response 302 or 307 with new URL location header) or forward with new URI.

If you want to redirect use this code (Never insert the Host header in the redirect if the protocol and the host are the same than the client request):

```tcl
when HTTP_REQUEST {
     don't evaluate the uri but the path (without query string) 
    if { [HTTP::host] equals "restricted-list" && [HTTP::path] equals "/"} {
         Change only the path part, keep the query string
         Use 307 instead of 302 (default redirect command) to force the client to post data if the first request was a POST.
        HTTP::respond 307 Location "/prl-ws/[HTTP::uri]"
    }
}

```

If you want to forward and change the URI in serverside request

```tcl
when HTTP_REQUEST {
     don't evaluate the uri but the path (without query string) 
    if { [HTTP::host] equals "restricted-list" && [HTTP::path] equals "/"} {
         Change only the path part, keep the query string
        HTTP::path "/prl-ws//"
    }
}

```

---

<div class="post-metadata">

**Author:** ![Mohammed\_Taher](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/mohammed_taher/32/2500_2.png) [@Mohammed\_Taher](https://community.f5.com/u/Mohammed_Taher)\
**Post date:** [January 23, 2023, 8:23am UTC](https://community.f5.com/t/adding-a-uri-using-irule/21000/4 "2023-01-23T08:23:07Z")

</div>

Apprecaited your help

[Stanislas\_Piro2​🌹](https://community.f5.com/user/261033)
