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

Filter by:
  • Solution
  • Technology
Clear all filters
Answers

HTTP URI redirection to specific URL

Hi - i have a following scenario;

HTTP VS - http://www.abc.com (redirecting to HTTPS) HTTPS VS - https://www.abc.com

Now customer wants to implement the following logic;

If anyone go to http://www.abc.com/CustomAB/* redirects it to http://xyz.test.com/services.txt

I have tried this irule on HTTP VS but it doesn't work ...

when HTTP_REQUEST { if { [HTTP::host] equals "http://www.abc.com"; and [HTTP::path] equals "/CustomAB/*" } { HTTP::redirect "http://xyz.test.com/services.txt"; } else { HTTP::redirect "https://[HTTP::host][HTTP::uri]" } }

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Try this (untested):

when HTTP_REQUEST { 
    if { ([HTTP::host] eq "www.abc.com") and ([HTTP::uri] starts_with "/CustomAB/") } { 
        HTTP::redirect "http://xyz.test.com/services.txt" 
        } else { 
        HTTP::redirect "https://[HTTP::host][HTTP::uri]" 
        } 
}
0
Comments on this Answer
Comment made 23-Mar-2017 by OmarKhan 54

Nope ..i have tested its not working ...i have applied this irule on HTTP VS but it doesn't work somehow...not redirecting the specific URI to other URL

0
Comment made 24-Mar-2017 by Vijay 4944

I fixed the previous iRule that had syntax errors.

Use curl to identify the response. curl -IL http://www.abc.com/CustomAB/

If that doesn't help use log local0. statements as shown here.

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Hi,

[HTTP::host] contains only the host name without protocol (http, https).

when HTTP_REQUEST { 
    if { [HTTP::host] equals "www.abc.com" and [HTTP::uri] starts_with "/CustomAB/" } { 
        HTTP::redirect "http://xyz.test.com/services.txt" 
        } else { 
        HTTP::redirect "https://[HTTP::host][HTTP::uri]" 
        } 
}
0
Comments on this Answer
Comment made 27-Mar-2017 by OmarKhan 54

Thanks Angelo, it works

0