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

Filter by:
  • Solution
  • Technology
Answers

HTTP to HTTPS redirect with URI editing.

Hi,

I am looking for HTTP (internal server) to HTTPS (external server) redirect.

link for internal server : http://abc.com/IT/Team/Data/ external link : https://xyz.com/location/Data/

I tried creating redirect using policy with following action

Target : http-reply Event : request Action : redirect Parameter : location https://xyz.com[HTTP::uri]

This works only if URI in original and redirected site is same as shown bellow

link for internal server : http://abc.com/IT/Team/Data/ external link : https://xyz.com/IT/Team/Data/

But in my case traffic get redirected using URL https://xyz.com/IT/Team/Data/

How I can update URI in redirected link so that it replace /IT/Team/ from URI to /location/

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Ok got the solution following rule works.

when HTTP_REQUEST { if {[HTTP::uri] contains "/IT/Team/"} { set uri [string map {"/IT/Team/" "/location/"} [HTTP::uri]] HTTP::redirect "https://xyz.com$uri" } }

0
Comments on this Answer
Comment made 14-Feb-2018 by Stanislas Piron 8592

you can simplify it with this code (HTTP::path instead of HTTP::uri, starts_with instead of contains):

when HTTP_REQUEST { 
    if {[HTTP::path] starts_with "/IT/Team/"} { 
        HTTP::redirect "https://xyz.com[string map {"/IT/Team/" "/location/"} [HTTP::uri]]"
    } 
}

of use a policy with action (version 12 minimum):

redirect location : tcl:https://xyz.com[string map {"/IT/Team/" "/location/"} [HTTP::uri]]
0
Comment made 14-Feb-2018 by SANTOSH79 17

I have mapped DNS entry of Virtual Server to FQDN name abc.com using etc host file. so all http request with uri containing /IT/Team/ is redirected to xyz.com. But other request are getting dropped

getting following message

This page isn’t working abc.com redirected you too many times. Try clearing your cookies. ERR_TOO_MANY_REDIRECTS

How to make other request to go to original site abc.com ?

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

that will require an iRule, just search for path replacement irule or such here and you will find quite some examples.

0
Comments on this Answer
Comment made 14-Feb-2018 by SANTOSH79 17

Thanks.

0