# irule for redirection

**URL:** <https://community.f5.com/t/irule-for-redirection/61844>\
**Category:** Technical Forums\
**Tags:** irules, ltm, application-delivery\
**Created:** [April 2, 2020, 2:59pm UTC](https://community.f5.com/t/irule-for-redirection/61844 "2020-04-02T14:59:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rohan](https://avatars.discourse-cdn.com/v4/letter/r/f19dbf/32.png) [@Rohan](https://community.f5.com/u/Rohan)\
**Post date:** [April 2, 2020, 2:59pm UTC](https://community.f5.com/t/irule-for-redirection/61844/1 "2020-04-02T14:59:04Z")

</div>

I have below requirement and and I have draft below iRule, Will it work ?

a. If user try to access [http://abc.com/](http://abc.com/) or [http://10.10.10.10/](http://10.10.10.10/) redirects to [https://www.abcworld.com/](https://www.abcworld.com/)

b. If user try to access [http://abc.com/\](http://abc.com/%5C)\* or [http://10.10.10.10/\](http://10.10.10.10/%5C)\* redirects to [https://www.abc.com/\](https://www.abc.com/%5C)\*

Note: \* is means any uri.

[abc.com](http://abc.com) = 10.10.10.10

[www.abcworld.com](http://www.abcworld.com) = 1.2.3.4

[www.abc.com](http://www.abc.com) = 5.6.7.8

when HTTP\_REQUEST {

if { (([string tolower [HTTP::host]] eq “[abc.com](http://abc.com)”) || ([HTTP::host] eq “10.10.10.10”)) && ([HTTP::uri] eq “/”) } then

{

HTTP::redirect “[https://www.abcworld.com/](https://www.abcworld.com/)”

}

elseif { ([string tolower [HTTP::host]] eq “[abc.com](http://abc.com)”) || ([HTTP::host] eq “10.10.10.10”) } then

{

HTTP::redirect “[https://www.abc.com](https://www.abc.com)[HTTP::uri]”

}

else {

}

}

---

<div class="post-metadata">

**Author:** ![Samir](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/samir/32/13073_2.png) [@Samir](https://community.f5.com/u/Samir)\
**Post date:** [April 2, 2020, 3:18pm UTC](https://community.f5.com/t/irule-for-redirection/61844/2 "2020-04-02T15:18:11Z")

</div>

This will not work. Go to devcentral iRule syntex and try once again.

---

<div class="post-metadata">

**Author:** ![Rohan](https://avatars.discourse-cdn.com/v4/letter/r/f19dbf/32.png) [@Rohan](https://community.f5.com/u/Rohan)\
**Post date:** [April 3, 2020, 10:41am UTC](https://community.f5.com/t/irule-for-redirection/61844/3 "2020-04-03T10:41:05Z")

</div>

why it will not work, Any specific reason ?

---

<div class="post-metadata">

**Author:** ![Samir](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/samir/32/13073_2.png) [@Samir](https://community.f5.com/u/Samir)\
**Post date:** [April 3, 2020, 11:06am UTC](https://community.f5.com/t/irule-for-redirection/61844/4 "2020-04-03T11:06:57Z")

</div>

Is it working for you? Did you check? Always connection go here.

​

​HTTP::redirect “[https://www.abcworld.com/](https://www.abcworld.com/)”

​

You need to modify iRule.​

---

<div class="post-metadata">

**Author:** ![Rohan](https://avatars.discourse-cdn.com/v4/letter/r/f19dbf/32.png) [@Rohan](https://community.f5.com/u/Rohan)\
**Post date:** [April 17, 2020, 10:57am UTC](https://community.f5.com/t/irule-for-redirection/61844/5 "2020-04-17T10:57:49Z")

</div>

Its Worked, There is and clause in irule, so first Condition will only hit when URL is [abc.com/](http://abc.com/) or [abc.com](http://abc.com) and 2nd Condition will hit when request URL is [abc.com/test](http://abc.com/test)
