Forum Discussion

OmarKhan_249581's avatar
OmarKhan_249581
Icon for Nimbostratus rankNimbostratus
Mar 23, 2017

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 "; and [HTTP::path] equals "/CustomAB/*" } { HTTP::redirect "; } else { HTTP::redirect "https://[HTTP::host][HTTP::uri]" } }

 

2 Replies

  • 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]" 
            } 
    }
    
  • 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]" 
            } 
    }