Forum Discussion

krish_net_18726's avatar
krish_net_18726
Icon for Nimbostratus rankNimbostratus
Jul 25, 2015

301 redirection issue

301 redirection issue

 

We are facing issue while trying to get the 302 to 301 redirection on LB.

 

We are using following i-rule for achiving this.

 

I-rule for 301 redirection....

 

when HTTP_REQUEST { if { [HTTP::host] equals "abc.co.in" } { if {!( [HTTP::path] equals "/")} { HTTP::respond 301 Location "https://www.abc.co.in[HTTP::path]" } } }

 

But instead of this we also have 4 I-rules that are running under the same VIP. Is this cousing issue for not getting redirection to 301 ?

 

Rule -1 -->

 

when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/" { HTTP::redirect "https://[HTTP::host]/home.aspx" } } }

 

Rule --> 2

 

when HTTP_REQUEST { if { [string tolower [HTTP::host]] eq "abc.co.in" } { HTTP::redirect "[HTTP::host][HTTP::uri]" } }

 

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

 

Rule ---> 3

 

when HTTP_REQUEST { set the URL here, log it on the response set http_request_time [clock clicks -milliseconds] set url [HTTP::host][HTTP::uri] set vip [IP::local_addr]:[TCP::local_port] }

 

when HTTP_RESPONSE { set client [IP::client_addr]:[TCP::client_port] set node [IP::server_addr]:[TCP::server_port] set nodeResp [HTTP::status] set http_response_time [ clock clicks -milliseconds ] set cn1 [expr $http_response_time - $http_request_time] log connection info log local0.info " MYUNIVERSE PORTAL : TOTAL-TIME (msec): $cn1 REQUEST-TIME(msec): $http_request_time RESPONSE-TIME(msec) : $http_response_time ---> Client: $client ---> VIP: $vip ---> Node: $node" }

 

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

 

Request you to please help me to get this resolve...

 

2 Replies

  • would u to format the code above. So we can have a clear understanding of your question.

     

    there is one button "Preformatted code" if u edit or create this question. 1:select the code 2:click "Preformatted code" button which sits in the forth seat from left to right.

     

  • The answer is "yes, probably". The second iRule also checks for the same Host header. If there is more than one iRule associated with a VS they must either use priorities to determine order, or they fire in the order they load (which, to you, is essentially non-deterministic). You should add priorities or consolidate the logic to a single rule.