# Simple I rule redirect

**URL:** <https://community.f5.com/t/simple-i-rule-redirect/23754>\
**Category:** Technical Forums\
**Tags:** irules, dev, devops, application-delivery\
**Created:** [June 24, 2013, 5:26pm UTC](https://community.f5.com/t/simple-i-rule-redirect/23754 "2013-06-24T17:26:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shawn306\_84070](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@shawn306\_84070](https://community.f5.com/u/shawn306_84070)\
**Post date:** [June 24, 2013, 5:26pm UTC](https://community.f5.com/t/simple-i-rule-redirect/23754/1 "2013-06-24T17:26:36Z")

</div>

Hello,

I have created a vip that used http redirect to https. Right now I am using the default redirect irule

when HTTP\_REQUEST {

HTTP::redirect https://[HTTP::host][HTTP::uri]

}

so basically when the customer types in the following

[http://abc.com/wfc/logon](http://abc.com/wfc/logon) it automatically redirects to

[https://abc.com/wfc/logon](https://abc.com/wfc/logon)

Fine no issues there.

The customer would like though to be also to type in the following and have it redirect like this.

[http://abc/wfc/logon](http://abc/wfc/logon)

and have that redirect to

[https://abc.com/wfc/logon](https://abc.com/wfc/logon).

I tried doing it on the port 80 part of the vip with

when HTTP\_REQUEST {

if { [HTTP::host] eq “abc” } {

HTTP::redirect “[https://abc.com/wfc/logon](https://abc.com/wfc/logon)”

}

}

That though did not work.

So do I put it on the 443 side on the vip. (I used the templates to set this up) or is my syntax screwed up here.

Thanks

Shawn

---

<div class="post-metadata">

**Author:** ![Kevin\_Stewart](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_stewart/32/15267_2.png) [@Kevin\_Stewart](https://community.f5.com/u/Kevin_Stewart)\
**Post date:** [June 24, 2013, 6:25pm UTC](https://community.f5.com/t/simple-i-rule-redirect/23754/2 "2013-06-24T18:25:51Z")

</div>

I believe that SHOULD work. You may want to throw in some logging to see what the BIG-IPs sees as the [HTTP::host] value, but otherwise:

```tcl
when HTTP_REQUEST {
     if { [string tolower [HTTP::host]] equals "abc" } {
          HTTP::redirect "https://abc.com[HTTP::uri]"
     } else {
          HTTP::redirect https://[HTTP::host][HTTP::uri]
     }
}

```

---

<div class="post-metadata">

**Author:** ![shawn306\_84070](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@shawn306\_84070](https://community.f5.com/u/shawn306_84070)\
**Post date:** [June 24, 2013, 7:05pm UTC](https://community.f5.com/t/simple-i-rule-redirect/23754/3 "2013-06-24T19:05:14Z")

</div>

worked like a charm. Many Thanks !!!
