# I-Rule Redirect Exception

**URL:** <https://community.f5.com/t/i-rule-redirect-exception/50172>\
**Category:** Technical Forums\
**Tags:** irules, application-delivery\
**Created:** [October 27, 2019, 9:43am UTC](https://community.f5.com/t/i-rule-redirect-exception/50172 "2019-10-27T09:43:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![raf](https://avatars.discourse-cdn.com/v4/letter/r/848f3c/32.png) [@raf](https://community.f5.com/u/raf)\
**Post date:** [October 27, 2019, 9:43am UTC](https://community.f5.com/t/i-rule-redirect-exception/50172/1 "2019-10-27T09:43:29Z")

</div>

Hello,

Can you please help me merge the following 3 exceptions into one I rule,

http://\<dns\>/\*/Raf.Services/\*

http://\<dns\>/\*/Raf.Rest/\*

http://\<dns\>/Raf.Api/\*

I did the test with “Raf.Services”, it works very well, now I want to add the 2 others in the same I rule:

http://\<dns\>/\*/Raf.Rest/\*

http://\<dns\>/Raf.Api/\*

The goal is to do,

**when HTTP\_REQUEST {**

**if { not ([HTTP::uri] contains “Raf.Services”)} {**

**log local0. “--redirect-- Request : [HTTP::uri]”**

**HTTP::redirect https://[getfield [HTTP::host] “:” 1][HTTP::uri]**

**} else {**

**log local0. “--no redirect-- Request : [HTTP::uri]”**

**}**

**if { not ([HTTP::uri] contains “Raf.Api”)} {**

**log local0. “--redirect-- Request : [HTTP::uri]”**

**HTTP::redirect https://[getfield [HTTP::host] “:” 1][HTTP::uri]**

**} else {**

**log local0. “--no redirect-- Request : [HTTP::uri]”**

**}**

**if { not ([HTTP::uri] contains “Raf.Rest”)} {**

**log local0. “--redirect-- Request : [HTTP::uri]”**

**HTTP::redirect https://[getfield [HTTP::host] “:” 1][HTTP::uri]**

**} else {**

**log local0. “--no redirect-- Request : [HTTP::uri]”**

**}**

if { [string tolower [HTTP::method]] eq “post” } {

if { [HTTP::header exists “Content-Length”] } {

if { [HTTP::header “Content-Length”] \> 1048000 }{

set content\_length 1048000

} else {

set content\_length [HTTP::header “Content-Length”]

}

} else {

set content\_length 1048000

}

if { $content\_length \> 0 } {

HTTP::collect $content\_length

}

}

}

P.S: The part I want to modify is in bold

Thank You

---

<div class="post-metadata">

**Author:** ![Enes\_Afsin\_Al](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/enes_afsin_al/32/15359_2.png) [@Enes\_Afsin\_Al](https://community.f5.com/u/Enes_Afsin_Al)\
**Post date:** [October 27, 2019, 6:01pm UTC](https://community.f5.com/t/i-rule-redirect-exception/50172/2 "2019-10-27T18:01:17Z")

</div>

Hi,

Can you try this?

```tcl
when HTTP_REQUEST {
	switch -glob [HTTP::uri] {
		"*/Raf.Services/*" -
		"*/Raf.Rest/*" -
		"/Raf.Api/*" {
			log local0. "--no redirect-- Request : [HTTP::uri]"
		}
		default {
			log local0. "--redirect-- Request : [HTTP::uri]"
			HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
		}
	}
}

```
