# Query on redirection

**URL:** <https://community.f5.com/t/query-on-redirection/54096>\
**Category:** Technical Forums\
**Tags:** irules, ltm, application-delivery\
**Created:** [April 26, 2016, 6:24pm UTC](https://community.f5.com/t/query-on-redirection/54096 "2016-04-26T18:24:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cyril](https://avatars.discourse-cdn.com/v4/letter/c/35a633/32.png) [@Cyril](https://community.f5.com/u/Cyril)\
**Post date:** [April 26, 2016, 6:24pm UTC](https://community.f5.com/t/query-on-redirection/54096/1 "2016-04-26T18:24:58Z")

</div>

Hello All,

I have the below URL redirection requirement and I’m not sure if this is possible or not.

[https://abcd.maintenance.com](https://abcd.maintenance.com) needs to be redirected to [https://www.maintenance.com](https://www.maintenance.com)

where

[https://abcd.maintenance.com/management](https://abcd.maintenance.com/management) & [https://abcd.maintenance.com/reports](https://abcd.maintenance.com/reports) should not be effected after redirection.

Requesting your kind help on this using iRule or redirect policy, thanks in advance.

-Cyril

---

<div class="post-metadata">

**Author:** ![Greg\_Labelle\_31](https://avatars.discourse-cdn.com/v4/letter/g/f475e1/32.png) [@Greg\_Labelle\_31](https://community.f5.com/u/Greg_Labelle_31)\
**Post date:** [April 26, 2016, 6:27pm UTC](https://community.f5.com/t/query-on-redirection/54096/2 "2016-04-26T18:27:02Z")

</div>

Based on your example, are you asking that only the root uri “/” be redirect, and not “/management”, or are you asking that the URI just not be manipulated?

---

<div class="post-metadata">

**Author:** ![Theo\_12742](https://avatars.discourse-cdn.com/v4/letter/t/eb9ed0/32.png) [@Theo\_12742](https://community.f5.com/u/Theo_12742)\
**Post date:** [April 26, 2016, 6:33pm UTC](https://community.f5.com/t/query-on-redirection/54096/3 "2016-04-26T18:33:23Z")

</div>

Certainly. You can access the [HTTP::host](https://devcentral.f5.com/wiki/iRules.HTTP__host.ashx) and [HTTP::uri](https://devcentral.f5.com/Wiki/iRules.HTTP__uri.ashx) variables and evaluate them separately.

I’d suggest using the Policy for readability, but the iRule would look like (untested):

```tcl
when HTTP_REQUEST {
    if { [HTTP::host] == "abcd.maintenance.com" and ([HTTP::uri] == "/" or [HTTP::uri] == "") } {
        redirect "https://www.maintenance.com/"
    }
}

```

---

<div class="post-metadata">

**Author:** ![Cyril](https://avatars.discourse-cdn.com/v4/letter/c/35a633/32.png) [@Cyril](https://community.f5.com/u/Cyril)\
**Post date:** [April 26, 2016, 6:34pm UTC](https://community.f5.com/t/query-on-redirection/54096/4 "2016-04-26T18:34:54Z")

</div>

Hi Greg, Thanks for your swift response. If I access the domain alone “[https://abcd.maintenance.com](https://abcd.maintenance.com)” it should be redirected to [https://www.maintenance.com](https://www.maintenance.com). But the above redirection should not impact the below URLs when accessed. [https://abcd.maintenance.com/management](https://abcd.maintenance.com/management) & [https://abcd.maintenance.com/reports](https://abcd.maintenance.com/reports) should not be effected after redirection.
