Forum Discussion

a_basharat_2591's avatar
a_basharat_2591
Icon for Nimbostratus rankNimbostratus
Nov 03, 2016
Solved

Rule for Policies to Redirect a specific URL

Hi,

 

I have tested the Irules for redirection, but want to do the same with Policies/Rules, So what I have done is:

 

  1. Create a new Policy
  2. Create a new Rule inside that Policy for the HTTP redirection to https://google.co.uk

Please see the image how I have configured the Rule, but it is not redirecting, Do I need on the "Match Section" use a different parameters? At the moment I am using HTTP referrer to a full string.. Do I need to put another thing to match the given URL wich is https://testredirection.com?

 

 

  • Please try these irule. Hope it will work as per your requirement.

        when HTTP_REQUEST {
        if { [HTTP::host] equals "testredirection.com" } {
        HTTP::respond 301 Location "https://google.co.uk"
            }
      }
    

    OR

    when HTTP_REQUEST {
         switch -glob [HTTP::header "Referer"] {
        "https://testredirection.com/*" {
        HTTP::respond 301 Location "https://google.co.uk"
          }
            default {
      HTTP::redirect [HTTP::header "Referer"]
            }
         }
    }
    

5 Replies