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

Reg URL Redirection using IRule

Yugandhar
Nimbostratus
Nimbostratus

Hi,

 

Is it possible to redirect a particular HTTP request to a particular URL based on the hostname and all other HTTP requests for that VIP to another URL using the following iRule.

 

when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "site.com" } { HTTP::redirect "https://yoursite1.com"; } else {HTTP::redirect "https://mysite09.com";}

 

}

 

Is it mandatory to use [string tolower ] when we are matching a [HTTP::host] Or can the iRule be written as

 

when HTTP_REQUEST { if { [HTTP::host] equals "site.com" } { HTTP::redirect "https://yoursite1.com"; } else {HTTP::redirect "https://mysite09.com";}

 

}

 

Thanks,

 

Yugandhar.

 

1 REPLY 1

Yes, this is possible. The

string tolower
function isn't mandatory, but it's probably better to use it so you will catch all upper- and lowercase variations of the hostname.

I see you use semicolons in your iRule. You don't need these.