Forum Discussion

Kenny_Van_73892's avatar
Kenny_Van_73892
Icon for Nimbostratus rankNimbostratus
Sep 01, 2006

Prevent users access directly to uri from saved favorite

I wonder if someone can help me out, I'm kinda stumple on this and doesn't know where to start.

 

 

I have a website that is behind the Big IP v. 4.5.10. Let say the website is https://www.mycompany.com and its uri is /account. At first users have to log in the site, then they can access to their uri. If users save wwww.mycompany.com/account in their browser favorite or bookmark, then next time if they access to the site, it takes them directly to www.mycompany.com/account without getting to www.mycompany.com first and this what I don't want. I want users have to go to www.mycompany.com first even if their saved favorite or bookmark is as www.mycompany.com/account.

 

 

Can I write an irule to stop users access directly to www.mycompany.com/account?

 

 

Thanks in advance.
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    I think the best solution might be to set a session cookie, and redirect on requests for non-root URI's if they don't have it:
    when HTTP_REQUEST {
      if { ([string length [HTTP::uri]] > 1) }{
        if { not ([HTTP::cookie exists "SessionCookie"]) }{
          HTTP::redirect "http://www.mycompany.com/"
        }
      }
    } 
    when HTTP_RESPONSE {
      HTTP::cookie insert name "SessionCookie" value [expr { int(1000 * rand()) }]
    }

    HTH

    /deb