Forum Discussion

ema_128890's avatar
ema_128890
Icon for Nimbostratus rankNimbostratus
Jan 28, 2016
Solved

Https redirect

I'm trying to redirect https://test.com to https://test.com/testing. Here is what I have so far

 

when HTTP_REQUEST { if { [HTTP::host] equals "test.com" } { HTTP::redirect "https://test.com/testing" } }

 

I get redirected to https://test.com/testing but I'm getting an error "This webpage has a redirect loop" Thanks in advance.

 

  • You need to examine [HTTP::uri] as well. So that your if clause does not trigger for every request, but instead only for where uri is set to /.

    Something like this

    when HTTP_REQUEST { 
        if { [HTTP::host] equals "test.com" && [HTTP::uri] equals "/" } { 
           HTTP::redirect "https://test.com/testing"
        } 
    }
    

    /Andreas

2 Replies

  • AndOs's avatar
    AndOs
    Icon for Cirrostratus rankCirrostratus

    You need to examine [HTTP::uri] as well. So that your if clause does not trigger for every request, but instead only for where uri is set to /.

    Something like this

    when HTTP_REQUEST { 
        if { [HTTP::host] equals "test.com" && [HTTP::uri] equals "/" } { 
           HTTP::redirect "https://test.com/testing"
        } 
    }
    

    /Andreas