# HTTP URI redirection to specific URL

**URL:** <https://community.f5.com/t/http-uri-redirection-to-specific-url/12018>\
**Category:** Technical Forums\
**Tags:** asm-advanced-waf, irules, application-delivery\
**Created:** [March 23, 2017, 2:28am UTC](https://community.f5.com/t/http-uri-redirection-to-specific-url/12018 "2017-03-23T02:28:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![OmarKhan\_249581](https://avatars.discourse-cdn.com/v4/letter/o/13edae/32.png) [@OmarKhan\_249581](https://community.f5.com/u/OmarKhan_249581)\
**Post date:** [March 23, 2017, 2:28am UTC](https://community.f5.com/t/http-uri-redirection-to-specific-url/12018/1 "2017-03-23T02:28:52Z")

</div>

Hi - i have a following scenario;

HTTP VS - [http://www.abc.com](http://www.abc.com) (redirecting to HTTPS) HTTPS VS - [https://www.abc.com](https://www.abc.com)

Now customer wants to implement the following logic;

If anyone go to [http://www.abc.com/CustomAB/](http://www.abc.com/CustomAB/)\* redirects it to [http://xyz.test.com/services.txt](http://xyz.test.com/services.txt)

I have tried this irule on HTTP VS but it doesn’t work …

when HTTP\_REQUEST { if { [HTTP::host] equals "; and [HTTP::path] equals “/CustomAB/\*” } { HTTP::redirect "; } else { HTTP::redirect “https://[HTTP::host][HTTP::uri]” } }

---

<div class="post-metadata">

**Author:** ![Vijay\_E](https://avatars.discourse-cdn.com/v4/letter/v/4bbf92/32.png) [@Vijay\_E](https://community.f5.com/u/Vijay_E)\
**Post date:** [March 23, 2017, 2:40am UTC](https://community.f5.com/t/http-uri-redirection-to-specific-url/12018/2 "2017-03-23T02:40:31Z")

</div>

Try this (untested):

```tcl
when HTTP_REQUEST { 
    if { ([HTTP::host] eq "www.abc.com") and ([HTTP::uri] starts_with "/CustomAB/") } { 
        HTTP::redirect "http://xyz.test.com/services.txt" 
        } else { 
        HTTP::redirect "https://[HTTP::host][HTTP::uri]" 
        } 
}

```

---

<div class="post-metadata">

**Author:** ![Angelo\_V](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@Angelo\_V](https://community.f5.com/u/Angelo_V)\
**Post date:** [March 25, 2017, 12:11am UTC](https://community.f5.com/t/http-uri-redirection-to-specific-url/12018/3 "2017-03-25T00:11:55Z")

</div>

Hi,

[HTTP::host] contains only the host name without protocol (http, https).

```tcl
when HTTP_REQUEST { 
    if { [HTTP::host] equals "www.abc.com" and [HTTP::uri] starts_with "/CustomAB/" } { 
        HTTP::redirect "http://xyz.test.com/services.txt" 
        } else { 
        HTTP::redirect "https://[HTTP::host][HTTP::uri]" 
        } 
}

```
