Forum Discussion

Alexis_Verb__23's avatar
Icon for Nimbostratus rankNimbostratus
Jul 01, 2011

Irule redirect --> problem with character "#"




I'm facing trouble with creating a simple redirect irule. I want to redirect everthing from{sth} to{sth}.



Here is the irule I've written :






if { [HTTP::path] equals "/" and


([HTTP::header "User-Agent"] contains "iPhone"


or [HTTP::header "User-Agent"] contains "iPod"


or [HTTP::header "User-Agent"] contains "Android"


or [HTTP::header "User-Agent"] contains "Apple Mobile Safari")} {


HTTP::respond 301 "Location" ""




elseif { [HTTP::host] equals "" }{


HTTP::respond 301 "Location" "[HTTP::uri]"




else {


pool mywebsite-pool








Anayway, in the [HTTP::uri], I often have the "" character, and it does not work.



Example :



If I try with I am redirected to



Does anyone know how to deal with that?



Thanks a lot,




3 Replies

  • Colin_Walker_12's avatar
    Historic F5 Account
    It looks like you're making this a lot more complicated than it needs to be, unless I'm missing something. If all you want to do is ensure there is always a www on the host, all you'd need is:

    when HTTP_REQUEST {
      if{[HTTP::host] eq ""] {
        HTTP::redirect "[HTTP::uri]"

    That should take care of it for you regardless of the URI.

    If there is something more complicated that you're trying to do, I missed it. Let me know what it is and I'll take a look.

  • Clients shouldn't include an anchor tag in the request they send to the server. It's something that is used clientside on the browser to load specific content on the page. If you log the HTTP::uri value, you should see that the tag isn't present in requests.



  • @Colin,


    Thanks for the tip, I'll use the HTTP:redirect which seems much simpler.





    Thanks for the explanation. I understand now why I didn't see the anchor tag when logging it.