Forum Discussion

Mike_59458's avatar
Mike_59458
Icon for Nimbostratus rankNimbostratus
Sep 14, 2011

Redirect on URI

Looking for some help to finish off this irule. I am trying to redirect to http error message 401 if the virtual server gets HTTPS://MAIL.DOMAIN.COM/OWA. All other URI can pass but need to block the /OWA. What I have so far is:

 

when CLIENT_ACCEPTED {

 

HTTP::enable

 

}

 

when HTTP_REQUEST {

 

if { [HTTP::URI] eq /owa } then {

 

 

 

How do I return a 401 error?

 

Mike

 

 

 

4 Replies

  • You can use the HTTP::respond command. You can specify the HTTP Status Code.

     

     

    HTTP::respond 401

     

     

    http://devcentral.f5.com/wiki/iRules.HTTP__respond.ashx
  • So I have the below but iRules does not like line 5. What is the correct syntaxs?

     

     

    when HTTP_REQUEST {

     

    HTTP::enable

     

    }

     

    when HTTP_REQUEST {

     

    if {[string tolower [HTTP::URI]] eq /owa }

     

    then { HTTP::respond 401 }

     

    }

     

     

    Mike
  • Hi Mike,

    Try this and see how it works for you.

    
    when HTTP_REQUEST {
    HTTP::enable
    if {[string tolower [HTTP::uri]] eq "/owa" } {
    HTTP::respond 401
    }
    } 
    
  • Oh, I did not notice until I hit Submit.

     

     

    You might want to change the "eq" to "starts_with".