Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

Irule Redirection URL

Hi,

We would like to redirect from "https://apac.com/cit/* to "https://abc.com/Cit/RDC/default.htm";

Please assist with this iRule

Thank you

0
Rate this Question
Comments on this Question
Comment made 1 week ago by Senthil 59

I hope it should work with below iRule, Please correct me if am wrong. when HTTP_REQUEST { if { [HTTP::uri] eq "/" } { HTTP::redirect "https://abc.com/Cit/RDC/default.htm"; } }

0

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Try below

when HTTP_REQUEST {
    if { [HTTP::host] equals "abc.com" and [HTTP::uri] starts_with "/cit/*" } {
        HTTP::redirect "https://[HTTP::host]/Cit/RDC/default.htm"
    }
}
0
Comments on this Answer
Comment made 6 days ago by Senthil 59

Thanks for your update, let me try and update you.

0
Comment made 4 days ago by Senthil 59

Hi,

Small correction with my above request, we wanted to redirect from "https://apac.com/cit/* to ""https://abc.com/Cit/RDC/default.htm";

I mean /cit/* here *means after /cit/'all behind' redirect to ""https://abc.com/Cit/RDC/default.htm";

0
Comment made 4 days ago by Senthil 59

I have tried with below iRule but facing issue with error like "redirected many times " and page is not opening when HTTP_REQUEST { if { [HTTP::host] equals "abc.com" and [HTTP::uri] starts_with "/Cit" } { HTTP::redirect "https://[HTTP::host]/Cit/RDC/default.htm" } }

/Cit/"all behind"

0
Comment made 3 days ago by snl 305

if you want to do 301 redirect then use below sample , modify accordingly to your requirement

when HTTP_REQUEST {
    if { [string tolower [HTTP::uri]] starts_with "/cit/" } {
        set newuri [string map -nocase {"/cit/" "/cit/rdc/default.htm"} [HTTP::uri]]
        HTTP::respond 301 Location "https://abc.com${newuri}"        
    }
}
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Hi,

you can do it with a Local trafic policy instead of irule (Policies only support 302 redirect, not 301)

or you can correct your irule to :

when HTTP_REQUEST {
    if { [HTTP::host] equals "apac.com" and [string tolower [HTTP::uri]] starts_with "/cit" } {
        HTTP::redirect "https://abc.com/Cit/RDC/default.htm"
    }
}
0