# HTTP::is\_redirect error?

**URL:** <https://community.f5.com/t/http-is-redirect-error/59246>\
**Category:** Technical Forums\
**Tags:** dev, irules, devops, application-delivery\
**Created:** [March 9, 2009, 8:08pm UTC](https://community.f5.com/t/http-is-redirect-error/59246 "2009-03-09T20:08:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DeVon\_Jarvis](https://avatars.discourse-cdn.com/v4/letter/d/47e85d/32.png) [@DeVon\_Jarvis](https://community.f5.com/u/DeVon_Jarvis)\
**Post date:** [March 9, 2009, 8:08pm UTC](https://community.f5.com/t/http-is-redirect-error/59246/1 "2009-03-09T20:08:04Z")

</div>

I have built this iRule to simulate the “Redirect\_Rewrite modify” option.

when HTTP\_REQUEST {

Save the host

set host [string tolower [HTTP::host]]

}

when HTTP\_RESPONSE {

if {[HTTP::is\_redirect] and [HTTP::header exists “location”]} {

set location [string tolower [HTTP::header “location”]]

if { ($location starts\_with “http://”) and ($location contains $host)} {

set newloc “https://[substr [HTTP::header Location] 7]”

HTTP::header replace Location $newloc

}

}

}

Works good in test, but when I put it in production, I am getting this error occasionally.

Mar 9 12:49:21 tmm tmm[1729]: 01220001:3: TCL error: redirect\_to\_https\_matching - Illegal argument. Can’t execute in the current context. (line 1) invoked from within “HTTP::is\_redirect”

Any idea what is going on?

---

<div class="post-metadata">

**Author:** ![DeVon\_Jarvis](https://avatars.discourse-cdn.com/v4/letter/d/47e85d/32.png) [@DeVon\_Jarvis](https://community.f5.com/u/DeVon_Jarvis)\
**Post date:** [March 9, 2009, 9:45pm UTC](https://community.f5.com/t/http-is-redirect-error/59246/2 "2009-03-09T21:45:21Z")

</div>

BTW: I am on 9.4.6

I changed the code to test the HTTP::status for 301, 302, etc, and the error has changed.

when HTTP\_REQUEST {

Save the host

set host [string tolower [HTTP::host]]

}

when HTTP\_RESPONSE {

switch [HTTP::status] {

“301” -

“302” -

“303” -

“305” -

“307” {

set redirect 1

}

default {

set redirect 0

}

}

if {$redirect == 1} {

set location [string tolower [HTTP::header “Location”]]

if { ($location starts\_with “http://”) and ($location contains $host)} {

HTTP::header replace Location [string map -nocase { “http://” “https://” } [HTTP::header value Location]]

}

}

}

Mar 9 14:38:33 tmm tmm[1729]: 01220001:3: TCL error: redirect\_to\_https\_matching - Illegal argument. Can’t execute in the current context. (line 1) invoked from within “HTTP::status”

---

<div class="post-metadata">

**Author:** ![DeVon\_Jarvis](https://avatars.discourse-cdn.com/v4/letter/d/47e85d/32.png) [@DeVon\_Jarvis](https://community.f5.com/u/DeVon_Jarvis)\
**Post date:** [March 10, 2009, 6:38pm UTC](https://community.f5.com/t/http-is-redirect-error/59246/3 "2009-03-10T18:38:47Z")

</div>

I added priority to my iRule, causing it to run first, and the errors seem to have disappeared. Wonder what was happening in the other iRules that was breaking this? Any ideas?

The current iRule is:

when HTTP\_REQUEST priority 100 {

Save the host

set host [string tolower [HTTP::host]]

}

when HTTP\_RESPONSE priority 100 {

if {[HTTP::is\_redirect]} {

set location [string tolower [HTTP::header “Location”]]

if { ($location starts\_with “http://”) and ($location contains $host)} {

HTTP::header replace Location [string map -nocase { “http://” “https://” } [HTTP::header value Location]]

}

}

}

---

<div class="post-metadata">

**Author:** ![hoolio](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@hoolio](https://community.f5.com/u/hoolio)\
**Post date:** [March 11, 2009, 1:10pm UTC](https://community.f5.com/t/http-is-redirect-error/59246/4 "2009-03-11T13:10:30Z")

</div>

What is the other iRule doing? Is it redirecting the client in HTTP\_RESPONSE?

Aaron

---

<div class="post-metadata">

**Author:** ![sam\_111661](https://avatars.discourse-cdn.com/v4/letter/s/8e8cbc/32.png) [@sam\_111661](https://community.f5.com/u/sam_111661)\
**Post date:** [May 3, 2009, 5:17pm UTC](https://community.f5.com/t/http-is-redirect-error/59246/5 "2009-05-03T17:17:10Z")

</div>

I have a problem with 9.4.6 and came across this thread, I have noticed this after upgrading to 9.4.6.

May 3 19:13:42 tmm tmm[2269]: 01220001:3: TCL error: ir\_irule1 - Illegal argument. Can’t execute in the current context. (line 39) invoked from within “HTTP::respond 401”

Any idea what could be causing this?

Thanks

---

<div class="post-metadata">

**Author:** ![hoolio](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@hoolio](https://community.f5.com/u/hoolio)\
**Post date:** [May 5, 2009, 10:00am UTC](https://community.f5.com/t/http-is-redirect-error/59246/6 "2009-05-05T10:00:09Z")

</div>

Hi smallIP,

Can you post the iRule(s) enabled on the virtual server and any debug you have from /var/log/ltm? Does the error occur on every request?

Aaron
