Forum Discussion

southern_shred1's avatar
southern_shred1
Icon for Nimbostratus rankNimbostratus
Sep 11, 2018

Redirect Include URI

Hi

I'm having trouble with the following iRule.

The requirement is to redirect any requests to https://download.test.back.com to https://download.test.back.com/bred/publicweb/status/gifb

Any requests directly to https://download.test.back.com/bred/publicweb/status/gifb should be rejected

when HTTP_REQUEST { if { [HTTP::host] equals "download.test.back.com" && [HTTP::path] equals "/" } { HTTP::redirect "https://[HTTP::host][HTTP::uri]/bred/publicweb/status/gifb"

        }else {          
    if {[HTTP::uri] equals "/bred/publicweb/status/gifb" } {
    reject
    }
}

}

The response we are seeing towards the servers is something like this does not include the URI (/bred/publicweb/status/gifb)

----------------------------REQUEST--------------------------- URI=/MEkwRzBFMEMwQTAJBgUrDgMCGgUABBQ6UnYMs4JZvSkqZMdaftSSm1KopgQUIT1LBSePsKHPrvwmssmkgd76sn4CCHCEWSkqZPMv

I would like URL to be included on the way to the servers, like this:

----------------------------REQUEST--------------------------- URI=/bred/publicweb/status/gifb/MEkwRzBFMEMwQTAJBgUrDgMCGgUABBQ6UnYMs4JZvSkqZMdaftSSm1KopgQUIT1LBSePsKHPrvwmssmkgd76sn4CCHCEWSkqZPMv

Can someone point me in the right direction?

Thanks

  • Do you want to:

     

    • redirect /foo to /bred/publicweb/status/gifb/foo
    • deny /bred/publicweb/status/gifb
    • allow everything starting with /bred/publicweb/status/gifb/

    Redirect means there is a 302 response to client who send a new request with new URI!

     

  • I guess this code may do what expected

     

    when HTTP_REQUEST { 
        if { [HTTP::host] equals "download.test.back.com" && [HTTP::path] equals "/" } {     
            HTTP::redirect "/bred/publicweb/status/gifb[HTTP::uri]"
    
            } elseif {[HTTP::uri] equals "/bred/publicweb/status/gifb" } {
        HTTP::respond 403 content {request rejected}
        }
    }