# exceptions to redirects

**URL:** <https://community.f5.com/t/exceptions-to-redirects/28058>\
**Category:** Technical Forums\
**Tags:** irules, dev, devops, application-delivery\
**Created:** [June 9, 2008, 3:08pm UTC](https://community.f5.com/t/exceptions-to-redirects/28058 "2008-06-09T15:08:06Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![slackwaresuppor](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@slackwaresuppor](https://community.f5.com/u/slackwaresuppor)\
**Post date:** [June 9, 2008, 3:08pm UTC](https://community.f5.com/t/exceptions-to-redirects/28058/1 "2008-06-09T15:08:06Z")

</div>

can anyone help with this..

its not working

my code

class noSSL {

myutil

util\_forum

}

when HTTP\_REQUEST {

if { [matchclass [HTTP::uri] ends\_with $::noSSL] } {

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

}

}

error:

01070151:3: Rule [nsaonline.ch-non-https] error:

line 1: [undefined procedure: class] [class noSSL {

myutil

util\_forum

}]

line 8: [undefined procedure: HTTP:host] [HTTP:host]

line 8: [undefined procedure: HTTP:uri] [HTTP:uri]

---

<div class="post-metadata">

**Author:** ![Andy\_Herrman\_22](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@Andy\_Herrman\_22](https://community.f5.com/u/Andy_Herrman_22)\
**Post date:** [June 9, 2008, 3:24pm UTC](https://community.f5.com/t/exceptions-to-redirects/28058/2 "2008-06-09T15:24:06Z")

</div>

Are you trying to define the class within the iRule itself? I don’t think that works. I’m pretty sure you have to declare the class separately (as a datagroup). Try that.

---

<div class="post-metadata">

**Author:** ![slackwaresuppor](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@slackwaresuppor](https://community.f5.com/u/slackwaresuppor)\
**Post date:** [June 9, 2008, 3:30pm UTC](https://community.f5.com/t/exceptions-to-redirects/28058/3 "2008-06-09T15:30:29Z")

</div>

where would i do that?

---

<div class="post-metadata">

**Author:** ![slackwaresuppor](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@slackwaresuppor](https://community.f5.com/u/slackwaresuppor)\
**Post date:** [June 9, 2008, 3:33pm UTC](https://community.f5.com/t/exceptions-to-redirects/28058/4 "2008-06-09T15:33:55Z")

</div>

ahhh!.. found the datagroups

---

<div class="post-metadata">

**Author:** ![slackwaresuppor](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@slackwaresuppor](https://community.f5.com/u/slackwaresuppor)\
**Post date:** [June 9, 2008, 3:37pm UTC](https://community.f5.com/t/exceptions-to-redirects/28058/5 "2008-06-09T15:37:52Z")

</div>

ok so i defined my datagroup,

and i still get :

01070151:3: Rule [nsaonline.ch-nonssl] error:

line 3: [undefined procedure: HTTP:host] [HTTP:host]

line 3: [undefined procedure: HTTP:uri] [HTTP:uri]

---

<div class="post-metadata">

**Author:** ![Andy\_Herrman\_22](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@Andy\_Herrman\_22](https://community.f5.com/u/Andy_Herrman_22)\
**Post date:** [June 9, 2008, 5:27pm UTC](https://community.f5.com/t/exceptions-to-redirects/28058/6 "2008-06-09T17:27:01Z")

</div>

Try putting the URL in quotes:

```tcl
when HTTP_REQUEST { 
   if { [matchclass [HTTP::uri] ends_with $::noSSL] } { 
     HTTP::redirect "http://[HTTP:host][HTTP:uri]" 
   } 
 }

```

I’m not sure if it’s required (I forget the exact TCL rules about this stuff), but it’s the only thing I see that might be wrong.

---

<div class="post-metadata">

**Author:** ![slackwaresuppor](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@slackwaresuppor](https://community.f5.com/u/slackwaresuppor)\
**Post date:** [June 9, 2008, 5:40pm UTC](https://community.f5.com/t/exceptions-to-redirects/28058/7 "2008-06-09T17:40:19Z")

</div>

same thing..

when HTTP\_REQUEST {

if { [matchclass [HTTP::uri] ends\_with $::nonSSL-nsaonline.ch] } {

HTTP::redirect “http://[HTTP::host][HTTP:uri]”

}

}

01070151:3: Rule [nsaonline.ch-nonssl] error:

line 3: [undefined procedure: HTTP:uri] [HTTP:uri]

---

<div class="post-metadata">

**Author:** ![slackwaresuppor](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@slackwaresuppor](https://community.f5.com/u/slackwaresuppor)\
**Post date:** [June 9, 2008, 7:52pm UTC](https://community.f5.com/t/exceptions-to-redirects/28058/8 "2008-06-09T19:52:38Z")

</div>

still getting this error

01070151:3: Rule [nsaonline.ch-nonssl] error:

line 3: [undefined procedure: HTTP:uri] [HTTP:uri]

---

<div class="post-metadata">

**Author:** ![Andy\_Herrman\_22](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@Andy\_Herrman\_22](https://community.f5.com/u/Andy_Herrman_22)\
**Post date:** [June 9, 2008, 8:15pm UTC](https://community.f5.com/t/exceptions-to-redirects/28058/9 "2008-06-09T20:15:36Z")

</div>

I think I see it. You only have 1 ‘:’ where you need 2.

```tcl
when HTTP_REQUEST {  
   if { [matchclass [HTTP::uri] ends_with $::noSSL] } {  
     HTTP::redirect "http://[HTTP::host][HTTP::uri]"  
   }  
 }

```

---

<div class="post-metadata">

**Author:** ![slackwaresuppor](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@slackwaresuppor](https://community.f5.com/u/slackwaresuppor)\
**Post date:** [June 9, 2008, 8:38pm UTC](https://community.f5.com/t/exceptions-to-redirects/28058/10 "2008-06-09T20:38:51Z")

</div>

SWEET that was it.. THANKS!!!

cant believe i didnt see that.

---

<div class="post-metadata">

**Author:** ![slackwaresuppor](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@slackwaresuppor](https://community.f5.com/u/slackwaresuppor)\
**Post date:** [June 10, 2008, 12:17pm UTC](https://community.f5.com/t/exceptions-to-redirects/28058/11 "2008-06-10T12:17:58Z")

</div>

ok.. so ive come to this

http profile:

when HTTP\_REQUEST {

if { [HTTP::uri] ends\_with “myjuiceplus” || [HTTP::uri] ends\_with “juiceplus\_forum” } {

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

}

else {

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

}

}

ssl profile:

when HTTP\_REQUEST {

if { [HTTP::uri] ends\_with “myjuiceplus” || [HTTP::uri] ends\_with “juiceplus\_forum” } {

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

}

}

and it kinda works.. when i hit the ssl page and navigate to the page that ends with myjuiceplus or juiceplus\_forum, it forwards to http

but the page says

The page isn’t redirecting properly

any ideas??

---

<div class="post-metadata">

**Author:** ![slackwaresuppor](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@slackwaresuppor](https://community.f5.com/u/slackwaresuppor)\
**Post date:** [June 10, 2008, 3:59pm UTC](https://community.f5.com/t/exceptions-to-redirects/28058/12 "2008-06-10T15:59:33Z")

</div>

got it..

needed to take out the

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

on the nonssl irule.
