Forum Discussion

swo0sh_gt_13163's avatar
swo0sh_gt_13163
Icon for Altostratus rankAltostratus
Nov 17, 2013

URI Based HTTP/HTTPs redirection.

Hello folks,

 

Can you please help me building an iRule with a specific requirement? The scenario is, a specific URI should not get redirect over HTTPs and rest of the traffic shall redirect to HTTPs.

 

For eg. http://mydomain.com/first/second/third - Should never go to HTTPs.

 

However when user tries to open http://mydomain.com, it should always redirect to https://mydomain.com/first/second I hope you understand the exact requirement.

 

Thanks folks! Darshan

 

3 Replies

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus

    How about modifying the default https redirect irule:

    When HTTP_REQUEST {
      if { not ([HTTP::uri] eq "/first/second/third") } {
        https://[getfield [HTTP::host] ":" 1][HTTP::uri]
        }
      }
    

    How does that look?

    N

  • Hey Nathan,

     

    Thanks for your help mate. I will give it a go and let you know. I am still newbie to F5. I didn't get meaning of 3rd line of the iRule. i.e.

     

    https://[getfield [HTTP::host] ":" 1][HTTP::uri]

     

    Could you please help me understand what does it mean how it will process the request?

     

    Thanks again, Darshan

     

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus

    Simply it's redirecting but it's also accounting for, and removing, any non standard http port (if one is being used of course e.g. 8080).

     

    Hope this helps.