Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 

irule redirect all except some path.

Hien_Truong
Cirrus
Cirrus

Hi,

i need to redirect all wildcard uri except some uri. The below irule is working with wildcard (else condition) but not working with others (if and elseif) condition. Please help to fix this issue. i appreciate it.

 

When HTTP_REQUEST {

if { ( [HTTP::host] eq "www.default.com") && ([HTTP::uri] starts_with "/abc/def")}

{ HTTP::respond "https://www.default.com/abc/def" }

elseif

{ ( [HTTP::host] eq "www.default.com") && ([HTTP::uri] starts_with "/xyz/w")}

{ HTTP::respond "https://www.default.com/xyz/w" }

else

{ HTTP::respond 301 Location "https://otherdomain.com/redirect_legacy[HTTP::uri]"

1 ACCEPTED SOLUTION

Hi Hien Truong,

when HTTP_REQUEST {
	if { [HTTP::host] equals "www.default.com" && not ([HTTP::uri] starts_with "/abc/def" || [HTTP::uri] starts_with "/xyz/w") } {
		HTTP::respond 301 Location "https://otherdomain.com/redirect_legacy[HTTP::uri]"
		return
	}
}

View solution in original post

2 REPLIES 2

Hi Hien Truong,

when HTTP_REQUEST {
	if { [HTTP::host] equals "www.default.com" && not ([HTTP::uri] starts_with "/abc/def" || [HTTP::uri] starts_with "/xyz/w") } {
		HTTP::respond 301 Location "https://otherdomain.com/redirect_legacy[HTTP::uri]"
		return
	}
}

Hien_Truong
Cirrus
Cirrus

​it works, thanks for your support. I appreciate it.