Forum Discussion

cpmurphy-3_1754's avatar
cpmurphy-3_1754
Icon for Nimbostratus rankNimbostratus
Nov 05, 2014

Issue with HTTP::URI with trailing /

First off I am an iRule newbie. I am having a bit of an issue with a trailing "/" in a redirect.

when HTTP_REQUEST {

if { [HTTP::uri] equals "/abc/" }{
HTTP::respond 301 Location "">
  }
if { [HTTP::uri] equals "/abc" }{
HTTP::respond 301 Location "">
  }

This is only a portion of the full rule. The issue is that when entering http://www.thisplace.com/abc the redirect works. However when entering http://www.thisplace.com/abc/, the redirect does not work. There are several other statements in the rule that are working without the trailing "/".

Thanks in advance.

4 Replies

  • Thank you for your quick reply. However I am curious as to why "equals" does not work? Would use "equals" in conjunction with HTTP::path?

     

  • R_Marc's avatar
    R_Marc
    Icon for Nimbostratus rankNimbostratus

    First, a switch statement is probably a better route. They are, I'm told, much faster in iRules than ifs. I'm also not sure what the second part of that responder is about (the ">http...").

    This would cover both of the above scenarios:

            switch -glob [HTTP::uri] {
                    "/abc*"  {
                            HTTP::respond 301 Location "
                    }
    
            }
    
    

    Response:

    GET /abc HTTP/1.0
    
    HTTP/1.0 301 Moved Permanently
    Location: ">http://www.someplace.com/blah/blah/
    Server: BigIP
    Connection: close
    Content-Length: 0
    
    GET /abc/ HTTP/1.0
    
    HTTP/1.0 301 Moved Permanently
    Location: ">http://www.someplace.com/blah/blah/
    Server: BigIP
    Connection: close
    Content-Length: 0
    
    
  • >However when entering http://www.thisplace.com/abc/, the redirect does not work. have you ever used http analyzer tool such as httpfox? it may be helpful in troubleshooting. HttpFox https://addons.mozilla.org/en-US/firefox/addon/httpfox/