Forum Discussion

stan_peachey_86's avatar
Nov 16, 2015
Solved

iRule to remove uri if it starts with a specific path

I'm trying to write an iRule (v11.6) that simply removes the entire uri if someone tries to enter a forbidden path. If host is https://foo.com and they try to add https://foo.com/console or any path...
  • Brad_Parker_139's avatar
    Nov 16, 2015

    A redirect is good here if you don't want to issue a 403. If you are going to use a redirect I would suggest a 301 to minimize on repeat traffic from users. 301 is a permanent redirect and the browser will do an internal redirect next time the browser visits vs 302 the browser will always hit your VIP to get the redirect.

    when HTTP_REQUEST {
        if { [string tolower [HTTP::uri]] starts_with "/console" } {
            HTTP::respond 301 noserver Location "https://[HTTP::host]"
        }
    }