Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

Irule Help

We have a site hosted in our webspere server which requires a http redirect.so i have created a irule with

when HTTP_REQUEST {

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

}
 
This left the WebSphere port in the redirect, how to remove the port ?
Please help with this.

Thanks
0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER
Hi Sams,

Here are a couple of Codeshare examples which should be relevant:

http://devcentral.f5.com/wiki/default.aspx/iRules/HTTPToHTTPSRedirect_301.html

http://devcentral.f5.com/wiki/default.aspx/iRules/RewriteHTTPRedirectPort.html

Aaron
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER
Aaron correct me if i am worng so the irule will be as below correct ? my concern is to remove webspere port because code can add the WebSphere port at any time.


when HTTP_REQUEST {

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

}

when HTTP_RESPONSE {

if { [HTTP::header is_redirect]} {

HTTP::header replace Location [string map ":[TCP::remote_port]/ /" [HTTP::header value Location]]
}
}
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER
If I understand your scenario correctly, that's close. You just need to strip out the port on requests:


when HTTP_REQUEST {

   # Remove the port from the host header if present and send a redirect to the same URI
   HTTP::redirect "http://[getfield [HTTP::host] : 1][HTTP::uri]"
}

when HTTP_RESPONSE {

   # Check if response is a redirect baseed on status code
   if { [HTTP::header is_redirect]} {

      # Update the location header by removing the pool member's port
      HTTP::header replace Location [string map ":[TCP::server_port]/ /" [HTTP::header value Location]]
   }
}


Aaron
0