# Irule Example Issue

**URL:** <https://community.f5.com/t/irule-example-issue/72763>\
**Category:** Technical Forums\
**Tags:** application-delivery\
**Created:** [July 24, 2023, 12:30pm UTC](https://community.f5.com/t/irule-example-issue/72763 "2023-07-24T12:30:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tfinkelstein](https://avatars.discourse-cdn.com/v4/letter/t/76d3ee/32.png) [@tfinkelstein](https://community.f5.com/u/tfinkelstein)\
**Post date:** [July 24, 2023, 12:30pm UTC](https://community.f5.com/t/irule-example-issue/72763/1 "2023-07-24T12:30:19Z")

</div>

Need help , i have F5 that i create i rule from [www.web.com/](http://www.web.com/)&nbsp;to redirect to&nbsp;[www.web.com/](http://www.web.com/)login , After user login he need to be redirected to&nbsp;[www.web.com/home.](http://www.web.com/)

I tried 2 IF on irule nothing work once i add additional rule after login its not working

---

<div class="post-metadata">

**Author:** ![whisperer](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/whisperer/32/13906_2.png) [@whisperer](https://community.f5.com/u/whisperer)\
**Post date:** [July 25, 2023, 1:07am UTC](https://community.f5.com/t/irule-example-issue/72763/2 "2023-07-25T01:07:05Z")

</div>

You can do the 1st redirect easily. I would actually suggest a Local Traffic Policy instead. However, the login page, where is that being performed? Application server or F5 APM session policy? If on the app server, you would need to perform the redirect there and not on the F5.

---

<div class="post-metadata">

**Author:** ![Paulius](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/paulius/32/21698_2.png) [@Paulius](https://community.f5.com/u/Paulius)\
**Post date:** [July 25, 2023, 5:16am UTC](https://community.f5.com/t/irule-example-issue/72763/3 "2023-07-25T05:16:48Z")

</div>

@tfinkelstein Does the end user receive any sort of cookie once they have successfuly logged into the system? If so you can configure an iRule to redirect to /login when only / is found and when a specific HTTP header such as a login cookie isn’t in the HTTP header but if it is then just send the user to /home. Please keep in mind that the F5 would not be validating the HTTP header value against any sort of user login even and would just be a search for value and perform said action. It would be up to the receiving server to validate that the user did log in and the HTTP value they provide is for the user session.

---

<div class="post-metadata">

**Author:** ![whisperer](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/whisperer/32/13906_2.png) [@whisperer](https://community.f5.com/u/whisperer)\
**Post date:** [July 25, 2023, 2:37pm UTC](https://community.f5.com/t/irule-example-issue/72763/4 "2023-07-25T14:37:41Z")

</div>

Paulius has a good point, if you know the name of the cookie being set by the application upon successfull login, you have have logic similar to the following:

```tcl
when HTTP_REQUEST {
  if { [HTTP::uri] equals "/" }
    HTTP::redirect "https://[HTTP::host]/login"
  }
  if { [HTTP::cookie exists "nameofcookie"] } {        
    HTTP::redirect "https://[HTTP::host]/home"       
  }        
}

```
