Forum Discussion

Wil_Schultz_101's avatar
Wil_Schultz_101
Icon for Nimbostratus rankNimbostratus
Oct 31, 2006

Long URI's, part II

I had this thread awhile ago and figured it out on v4, how would I do the same on v9?

Click here


else if (substr(http_uri, 0) > 255) {
redirect to "http://www.mysite.com" + substr(http_uri, 0, 254)
}

Thanks!

4 Replies

  • I don't think there is a 255 character limit on the URI in 9.x. Have you tested and found any issues?

    You should be able to use HTTP::uri to reference or set the URI. Check the iRules wiki for details, or post any questions you have.

    
    HTTP::redirect "http://www.mysite.com[HTTP::uri]"

    Thanks,

    Aaron
  • We have had problems in the past with people sending repeated URL over 8000 chars in length, stuff seemed to slow down quite a bit. I'm porting over v4 iRules to v9 so I'd like to carry over everything and tune later.

    So far I have:

    
     elseif { [substr [HTTP::uri] 0] > 513 } {
     HTTP::redirect "http://www.mysite.com"
     } 

    Weird thing, I can add this if it's the last rule but it won't allow me to add as the second rule...
  • Were you seeing problems in 9.x with long URIs? If so what kind of problems? I've tested 1024 character URIs previously with 9.x and not found any issues.

    Is that the full rule? You could also use string length to get the count of characters in the URI:

    
    ...
    elseif { [string length [HTTP::uri]] > 513 }{
       HTTP::redirect "http://www.mysite.com"
    }

    Can you post the full text of (both?) rules to see along with the error you're seeing?

    Thanks,

    Aaron

  • Right on, I could have sworn that I tried this exact syntax and did not see the results. Regardless, it is working now and I really appreciate the assistance. The exact syntax for the rule I have is:

    
    elseif { [string length [HTTP::uri]] > 513 }{
      log local0.longuri
      redirect to http://www.mysite.com[substr [HTTP::uri] 0 513]
    }

    The problem we were seeing before, on v4, was that someone far away on a home DSL had the ability to slow our site by sending long URL's. F5 support thought that it might be due to the amount of iRules that we had running and the box simply had to use too many cpu cycles running these through to get to other things properly. There is probably a more elegant solution but this is the first one that I though of...

    Thanks again, you all are great!