For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Dan_Kop_23221's avatar
Dan_Kop_23221
Icon for Nimbostratus rankNimbostratus
Dec 03, 2015

Redirect :: URI with # symbol

Have a URI that has "//hello"

 

We are looking to redirect anything that comes in with this to another URL. Here is what we have so far:

 

when HTTP_REQUEST {

 

if { [string tolower [HTTP::host]] equals "" } { HTTP::redirect "https://siteb.com/" } else { } }

 

We see that the iRule is Executed via our stats; however, the site is never redirected. Any thoughts on why this would not redirect?

 

6 Replies

  • Hi Dan,

     

    in the URI world the Hash-Sign () is called a "Fragment" and suppressed from sending by every browser.

     

    scheme:[//[user:password@]host[:port]][/]path[?query][fragment]

     

    So everthing after the Hash-Sign never hits the wire and therefor never reaches your F5.

     

    Cheers, Kai

     

  • Hi,

    your irule is not working for 2 reasons:

    • is not sent to the server
    • HTTP::host does not contain URI... in the request "" :

    The good syntax may have been (concatenate both variables):

    when HTTP_REQUEST { 
        if { [string tolower [HTTP::host][HTTP::uri]] equals "www.sitea.com//hello" } { 
            HTTP::redirect "https://siteb.com/" 
        }
    }
    

    But this is not possible... is a Fragment identifier managed locally by the browser, never sent to the server...

  • Hello folks,

     

    I thought "contains hello" will also work. Can anybody correct me?

     

    Thanks, R

     

  • Hi Root,

     

    in this specific scenario "contains hello" wouldn't work either, since everything byte after the hash-sign is getting excluded from the browsers HTTP request.

     

    URL in the address Bar : Url requested from server: www.sitea.com/

     

    The portion after the hash-sign is called "fragment" and a pure client site functionality to select or scroll down to a specific section of the requested ressource.

     

    For more information refer to: https://en.wikipedia.org/wiki/Fragment_identifierBasics

     

    Note: The Basics fragment of the Wiki site causes your Browser to jump to the section containing the code 'id="Basics"'

     

    To see what the browser is sending I'd recommend to use either Fiddler, HTTP-Watch or dump the entire HTTP request using iRules (e.g. "log [HTTP::request]"). Any of the tools would show you, that the client isn't even sending "/hello" to the server. And if this string is not send by the client the F5 can't make additional decissions based on this string, right?

     

    Cheers, Kai

     

  • I'm seeing the inclusion of the "" in the URL, entered into the browser, altering which page is actually delivered. NOTE: We have Glassfish in the back end.

     

    With NO redirects in place at all, we see the following behaviour when attempting to navigate to variations of the URL (just for demonstration purposes): FAILS (returns Glassfish 404 error): https://fqdn.blah.blah/myaccount/forms/moving

     

    SUCCESS (goes to a page about moving - the old page we want to redirect away from): https://fqdn.blah.blah/myaccount//forms/moving

     

    SUCCESS (goes to the myaccount page as expected) https://fqdn.blah.blah/myaccount/

     

    We need to redirect... FROM: https://fqdn.blah.blah/myaccount//forms/moving TO: https://fqdn.blah.blah/moving.html

     

    Problem is that, as you say, nothing after the goes through in the request and the path is actually /myaccount As I don't want to redirect /myaccount - does anyone know how to make this happen?

     

    Cheers, Brett