# iRule help

**URL:** <https://community.f5.com/t/irule-help/7904>\
**Category:** Technical Forums\
**Tags:** big-ip-access-policy-manager-apm, irules, ltm, application-delivery\
**Created:** [November 27, 2015, 5:00am UTC](https://community.f5.com/t/irule-help/7904 "2015-11-27T05:00:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![siru\_129409](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@siru\_129409](https://community.f5.com/u/siru_129409)\
**Post date:** [November 27, 2015, 5:00am UTC](https://community.f5.com/t/irule-help/7904/1 "2015-11-27T05:00:05Z")

</div>

Hi Can anyone help me to create an iRule. My scenario is as following , Users from outside (internet) will access the url _[https://mail.company.com/archive](https://mail.company.com/archive)_ for accessing their archived/old emails. but url on the archive server side is _[https://mycompany.archivemail.com/archive.](https://mycompany.archivemail.com/archive)_

_**[Mail.company.com](http://Mail.company.com)**_ is belongs to exchange 2013 server and the exchange service are load balanced and secured by BIG-IP LTM, APM and ASM. and the _**[mycompany.archivemail.com](http://mycompany.archivemail.com)**_ is belongs to a different server, and this URL is not publicly accessible (It’s using for accessing the old/archived emails only).

In order to achieve the same, I have created a pool with name **archive-pool** for the archive servers and the following iRule for changing the user requested url.

when HTTP\_REQUEST {

```tcl
if {[HTTP::uri] contains "/archive"}
         { 
         HTTP::header replace Host "mycompany.archivemail.com"
         Pool archive-pool
         }
         }

```

And the iRule is applied to the Exchange VS and placed on the top of Exchange\_2013\_apm\_combined\_pool\_irule7 (which is created by iAPP)) But its not working, I am getting the page not found error, If anyone can help to resolve this issue it would be highly appreciated.

---

<div class="post-metadata">

**Author:** ![eneR](https://avatars.discourse-cdn.com/v4/letter/e/e19adc/32.png) [@eneR](https://community.f5.com/u/eneR)\
**Post date:** [November 27, 2015, 9:38am UTC](https://community.f5.com/t/irule-help/7904/2 "2015-11-27T09:38:02Z")

</div>

I would do it this way:

```tcl
when HTTP_REQUEST {
if {[string tolower [HTTP::uri]] starts_with "/archive"} {
    HTTP::header replace "Host" "mycompany.archivemail.com"
    pool archive-pool
    }
}

```

---

<div class="post-metadata">

**Author:** ![siru\_129409](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@siru\_129409](https://community.f5.com/u/siru_129409)\
**Post date:** [November 28, 2015, 10:56am UTC](https://community.f5.com/t/irule-help/7904/3 "2015-11-28T10:56:47Z")

</div>

Hi This is not working for me, After applying this irule I could see my browser is redirecting to _[my.company.archivemail.com](http://my.company.archivemail.com)_ and getting a error message of server not found.

---

<div class="post-metadata">

**Author:** ![eneR](https://avatars.discourse-cdn.com/v4/letter/e/e19adc/32.png) [@eneR](https://community.f5.com/u/eneR)\
**Post date:** [November 30, 2015, 8:06am UTC](https://community.f5.com/t/irule-help/7904/4 "2015-11-30T08:06:33Z")

</div>

Well, for me the iRule looks fine but maybe any other one see’s the fault..

Personally i would write an

```tcl
log local0. "iRule xyz - Host: [HTTP::host][HTTP::uri] sent to [LB::server addr]"

```

into the irule and check the logs if everything looks like expected.

But i believe that the LB process as it self has nothing to do with the URL/URI. So if the irule gets executed and the if statement is true, the request gets forwarded to the configured pool.

Maybe there is something wrong with your pool-/member configuration?
