Forum Discussion

Tom_Thunem_9204's avatar
Tom_Thunem_9204
Icon for Nimbostratus rankNimbostratus
Jan 19, 2017

Capture a portion of a URI

Hello,

 

I am trying to capture a portion of a URI to append to a new URI and redirect. for example...

 

original request = https://domain.com/pcn/DownloadFile?ref=1cac6415-7446-4423-a29c-e0bda171c1f0

 

rewritten request = http://different-domain.com:6790/AttachmentURLRedirectPage.aspx?ref=1cac6415-7446-4423-a29c-e0bda171c1f0

 

In this case, the portion to capture from the original request to be inserted into the rewritten request is "?ref=1cac6415-7446-4423-a29c-e0bda171c1f0".

 

The values following "?ref" will change with each new request.

 

Hope I made sense. Thanks!

 

1 Reply

  • Try this (untested):

    when HTTP_REQUEST {
        if { ([HTTP::host] eq "domain.com") and ([HTTP::uri] contains "?ref=") } {
            HTTP::respond 301 Location "http://different-domain.com/AttachmentURLRedirectPage.aspx?[HTTP::query]"
        }
    }
    

    This link might explain a bit more.