Forum Discussion

tolinrome_13817's avatar
tolinrome_13817
Icon for Nimbostratus rankNimbostratus
Jul 17, 2014

Need to redirect to an external url

We want our users to be redirected to a secondary external url when they access the first url.

 

For example: When our users go to https://application.ourdomain.com (which points to our F5), I want them to go to https://external.link.com

 

What do I put in the iRule? Thanks!

 

  • You may use this irule to do so.

     

    when HTTP_REQUEST { if { [HTTP::host] equals "https://application.ourdomain.com" } { HTTP::respond 301 Location "https://external.link.com" } }

     

  • You may use this irule to do so.

     

    when HTTP_REQUEST { if { [HTTP::host] equals "https://application.ourdomain.com" } { HTTP::respond 301 Location "https://external.link.com" } }

     

  • Thank you for replying.

     

    Do I need to create a vip and redirect rule or just the vip? Does ssl client need to be enabled at all?

     

    Also, the first url users will access is http not https, so I dont know if that matters where you wrote:

     

    "equals "https://application.ourdomain.com" - should that be changed to http?

     

    • Mike_G_is_1_134's avatar
      Mike_G_is_1_134
      Icon for Nimbostratus rankNimbostratus
      I don't think that you need to put the "https://" part into the if comparison. HTTP::host is just the host value, in your example "application.ourdomain.com". As an alternative, you could also use the HTTP::redirect function instead of responding with the 301. Just a suggestion.
  • Hi, I'm trying to setup something similar but getting an issue with the vserver being up.

     

    I want to re-direct all 443 traffic from the vserver to an external url. 80 will just re-direct to 443. I think i'm ok with that but my virtual server is down. this is because it thinks the pool member(s) are down but there are no pool members as I just need it to re-direct to external.

     

    my question is how do I get around this?

     

    I tried to create a pool with no members and changed the Irule to show the following:

     

    when HTTP_REQUEST { if { [active_members Pool_test] == 0 }{ HTTP::redirect "" } }

     

    however, that still doesn't bring it up.

     

    any help would be great

     

    thanks in advance

     

    • StephanManthey's avatar
      StephanManthey
      Icon for MVP rankMVP
      Hi, if you are using your virtual servers for redirection only there is no need to assign a pool. Having an iRule to redirect to the external location is just fine. Your virtual servers will remain in "blue" (unknown) state. No test for number of available servers is required. I hope I got your question right. Thanks, Stephan