Forum Discussion
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:
- Create a new Policy
- 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
- Stanislas_Piro2
Cumulonimbus
your rule may never match as the referer may be http://testredirection.com/ and you search exact string http://testredirection.com (without /)
is = exact string starts_with = all URL starting with http://testredirection.com
- hari_126827
Cirrus
probably irule could also be helpful please look into below link: https://devcentral.f5.com/articles/irule-security-101-06-http-referer
- a_basharat
Nimbostratus
If I change the Rule [leaving all the parameters same] to http://testredirection.com/ [with /] it doesn't redirect either. So Do I need to use a different Match method?
- Samir_Jha_52506
Noctilucent
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"] } } } - Stanislas_Piro2
Cumulonimbus
Hi,
if you have tested it with irule, can you provide it to help you to create the same thing in policy.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
