Forum Discussion

3 Replies

  • giltjr's avatar
    giltjr
    Icon for Nimbostratus rankNimbostratus

    Somebody needs to write the web page to display the message and do the redirect. You can display the page they write by doing:

     

    set RedirectPage01 "html code goes here"
    if { ([string tolower [HTTP::host]] equals "www.foods.com") and ([HTTP::uri] equals "/")} {
    HTTP::respond 200 content $RedirectPage01 ; return
            }
  • giltjr's avatar
    giltjr
    Icon for Nimbostratus rankNimbostratus

    The "set" will set the value of the variable RedirectPage01 to what ever you put in between the quotes.

     

    [string tolower [HTTP::host]] will covert the value of the variable HTTP::host to lower case. HTTP::host is a variable set by the F5 and it the value of the host header in the HTTP request.

     

    ([string tolower [HTTP::host]] equals "www.foods.com") will check to see if it is equal to www.foods.com.

     

    ([HTTP::uri] equals "/") will check to see if the URI is just plain "/", that is it is not "/somepage.html".

     

    if { ([string tolower [HTTP::host]] equals "www.foods.com") and ([HTTP::uri] equals "/")} will check to see that both conditions are true and if they are both true the F5 will respond to the request sending the value of the variable RedirectPage01.

     

    So if the host name is the check for host name will fail and the F5 will continue with any other logic in your iRule. If there is no other logic, then the F5 will pass the request through to the servers behind the F5 as configured.

     

    If the hostname is but the URI is "/somepage.html", then the check for URI will fail and the F5 will continue with any other logic in your iRule. If there is no other logic, then the F5 will pass the request through to the servers behind the F5 as configured.

     

  • Hi MOHIT,

    here is a solution to inform the client before forcing the browser to open the new page:

    Redirect a VS via irule

    Just replace the IP addresses in the example by the new name, i.e.:
    when HTTP_REQUEST {
        set page "
        The site  has been retired. 
        After 5 seconds, you will automatically be redirected to our new page at "
        HTTP::respond 200 content "${page}" Content-Type "text/html"
    }
    

    Thanks, Stephan