Forum Discussion

LaurentG_53647's avatar
LaurentG_53647
Icon for Nimbostratus rankNimbostratus
May 05, 2015

401 redirection

Dear all

 

I would like to make a 401 redirection: I tried this irule but my website is directly redirected to google.com:

 

when HTTP_RESPONSE { if {[HTTP::status] == 401]}{ HTTP::redirect "https://google.com" } }

 

indeed when I connect to the website I am directly getting a popup to enter user + password (design of the website) but in the header a code 401 is directly sent when I access the page causing the direct redirection

 

Any ideas how I can address this issue ? thanks for your help

 

Thanks

 

4 Replies

  • Are you saying that you are getting a popup when you access the page and you don't want that? Have you seen this codeshare? It describes how to change the status code on a response. You could use the same concept to redirect the user instead of keeping the 401 status.

     

  • Right now when I access the page 1) I directly get a popup to enter user + password in header information the http status is appearing with HTTP/1.1 401 Unauthorized

     

    2) if I do no provide credentials I then I get the "HTTP Error 401.2 - Unauthorized: Access is denied due to server configuration" webpage --> I would like to redirect it to an other website or even to an error page

     

    thanls for the proposed codeshare but it is not helping in that case

     

  • is there any http response header that can differentiate 401.2 from 401? have you ever used http analyzer tool? it may be helpful to check the response header.

     

    HttpFox

     

    https://addons.mozilla.org/en-Us/firefox/addon/httpfox/

     

    otherwise, you may have to identify 401.2 response from response body e.g. using stream profile/irule, HTTP::collect irule command.

     

  • kunjan's avatar
    kunjan
    Icon for Nimbostratus rankNimbostratus

    How about this?

    when HTTP_RESPONSE {
      if { [HTTP::status] == 401 }{
        HTTP::respond 302 Location "https://google.com"
      }
    }