Forum Discussion

Riaz_125436's avatar
Riaz_125436
Icon for Nimbostratus rankNimbostratus
Jul 02, 2014

redirect for http and https VIPs

Hi, Need help to write an iRule to redirect traffic for http and https VIPs as:

 

HTTP VIP:

 

http://abc.com/ ----- redirect to http://abc.com/welcome

 

http://abc.com/welcome ----- redirect to http://abc.com/en/default/welcome

 

HTTPs VIP:

 

https://abc.com/ ----- redirect to https://abc.com/welcome

 

https://abc.com/welcome ----- redirect to https://abc.com/en/default/welcome

 

4 Replies

  • when HTTP_REQUEST { HTTP::respond 302 Location "https://[HTTP::host][HTTP::uri]" TCP::close }

     

  • Would it make more sense to just redirect to "/en/default/welcome" if the URI is empty?

    when HTTP_REQUEST {
        if { [HTTP::uri] equals "/" } {
            HTTP::redirect "http://[HTTP::host]/en/default/welcome"
        }
    }
    

    Replace "http://" with "https://" in the HTTPS VIP.

  • Try this:

    when HTTP_REQUEST {
        switch [string tolower [HTTP::uri]] {
            "/" -
            "/welcome" {
                HTTP::redirect "http://[HTTP::host]/en/default/welcome"
            }
        }
    }
    

    Assuming you're offloading the SSL for your HTTPS VIP traffic, the iRule should be the same except for the redirect scheme value (https:// vs. http://).

  • Let's look at this from a flow, based on your original description.

    1. user makes a request to "/" and is redirected to "/welcome"
    2. user returns with a request to "/welcome" and is redirected to "/en/default/welcome"
    

    At what point do you want users to land on "/welcome" and not redirect?