Forum Discussion

Arun_Bhardwaj_1's avatar
Mar 11, 2015

URL redirtion not happning through Irule.

Hi All,

 

I am using simple Irule to redirect Url.

 

when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "abc.com" } { HTTP::redirect "https://abc.com/welcome/do" } }

 

i attached this i rule to standard Virtual server for port 80. HTTP profile is enabled.

 

But at the time of testing URL redirection not happening....page opening without redirection i.e abc.com.

 

Please help what i am missing...?

 

7 Replies

  • If you use multiple iRules, another possible cause would be a TCL error (e.g. due to multiple redirect invocations). Take a brief look at the /var/log/ltm file as you initiate a connection. If this happens to be the case, use the

    event disable
    command after each redirect statement to ensure no more than one BigIP redirect will be invoked per request.

    • Arie's avatar
      Arie
      Icon for Altostratus rankAltostratus
      Good point, but wouldn't `event disable` risk disabling other (required) functionality? I usually implement a semaphore to prevent multiple responses.
  • If you use multiple iRules, another possible cause would be a TCL error (e.g. due to multiple redirect invocations). Take a brief look at the /var/log/ltm file as you initiate a connection. If this happens to be the case, use the

    event disable
    command after each redirect statement to ensure no more than one BigIP redirect will be invoked per request.

    • Arie's avatar
      Arie
      Icon for Altostratus rankAltostratus
      Good point, but wouldn't `event disable` risk disabling other (required) functionality? I usually implement a semaphore to prevent multiple responses.
  • giltjr's avatar
    giltjr
    Icon for Nimbostratus rankNimbostratus

    Depending on how your F5 is setup, wouldn't this cause a endless loop? You are only checking for the host name of abc.com and then redirecting to a specific URI at abc.com (https://abc.com/welcome/do).

     

    I would think you may want to check for the URI just equal to "/" and the host name abc.com.

     

  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus

    Something else you may want to consider (not related to the problem) is using a 301 instead of a 302.

    Instead of

    HTTP::redirect "https://abc.com/welcome/do" 
    

    I would recommend

    HTTP::respond 301 Location "https://abc.com/welcome/do"