Forum Discussion

XITO_122925's avatar
XITO_122925
Icon for Nimbostratus rankNimbostratus
Jul 04, 2013

Redirect specific url

Hallo iRule Fans

 

I have a problem with a iRule an hope anybody can help me.

 

The user logs in to the member are of the website https://website.com/Member

 

In the member area is a link that calls https://website.com/en/publicsearch

 

I need a iRule that redirects the URL form HTTPS to HTTP https://website.com/en/publicsearch to http://website.com/en/publicsearch

 

I have tried the irule but it doesn’t works L

 

when HTTP_REQUEST {

 

Save the url/uri so it will be available in the HTTP_RESPONSE

 

set uri [HTTP::uri]

 

}

 

when HTTP_RESPONSE {

 

if {not ($uri contains "/Member/")and([TCP::local_port] == 443)}

 

{

 

HTTP::redirect "http://$uri"

 

}

 

}

 

1 Reply

  • On the port 443 VIP:

     

    ========================

     

    when HTTP_REQUEST {

     

    if { [string tolower [HTTP::uri]] starts_with "/en/publicsearch" } {

     

    HTTP::redirect "http://[HTTP::host][HTTP::uri]"

     

    }

     

    }

     

    ========================

     

     

    On the port 80 VIP:

     

    ========================

     

    when HTTP_REQUEST {

     

    if { [string tolower [HTTP::uri]] starts_with "/member" } {

     

    HTTP::redirect "https://[HTTP::host][HTTP::uri]"

     

    }

     

    }

     

    ========================

     

     

    I would also add that switching between HTTP and HTTPS can cause havoc in some browsers. It may be better to just leave everything HTTPS from the member user's perspective.