Forum Discussion
redirect F5
- Jul 19, 2016
Hi,
if you are using an irule to do redirects, you just need to add a peace of code on the top of the irule to redirect the user in every condition like this :
when HTTP_REQUEST { HTTP::respond 302 Location "https:://www.example.com/" Connection Close return }You add those two lines at the top of the irule and all requests should be redirected to https://www.example.com. If you need to keep the original uri, you can change the redirect command by this one :
HTTP::respond 302 Location "https:://www.example.com/[HTTP::uri]" Connection CloseIf you are using LTM policies, you can add a rule at the top of your rule set to redirect all requests to the desired host
And finally, you can shutdown your assigned pool and add a fallback url in your http profile assigned to the Virtual Server.
Hi,
if you are using an irule to do redirects, you just need to add a peace of code on the top of the irule to redirect the user in every condition like this :
when HTTP_REQUEST {
HTTP::respond 302 Location "https:://www.example.com/" Connection Close
return
}You add those two lines at the top of the irule and all requests should be redirected to https://www.example.com. If you need to keep the original uri, you can change the redirect command by this one :
HTTP::respond 302 Location "https:://www.example.com/[HTTP::uri]" Connection CloseIf you are using LTM policies, you can add a rule at the top of your rule set to redirect all requests to the desired host
And finally, you can shutdown your assigned pool and add a fallback url in your http profile assigned to the Virtual Server.
- Lucilius_223799Jul 19, 2016
Nimbostratus
Would that mean i have to change the redirect url on all 40+ redirects that are currently active or it is possible to setup some global redirect and temporarily remove all the other redirects and then bring them back from the standby later on?
- Yann_Desmarest_Jul 19, 2016
Nacreous
Can you share an anomized example of your configuration ? Are you requesting to redirect traffic from all Virtual Servers or just one ?
Do you have all redirects in an irule, ltm policy or something else ?
- Lucilius_223799Jul 19, 2016
Nimbostratus
most redirect exist along the lines of this:
when HTTP_REQUEST { if { [HTTP::host] equals "xyz.com" }{ HTTP::respond 301 location "http://www.abc.com" } } - boneyardJul 19, 2016
MVP
so then you have many of these irules attached to one virtual server?
 
in that case you add another one with a lower priority then 500 (the default) so that one hits before the others, if you do it without the if as Yann suggests you got a nice way to enable / disable it.
 
https://devcentral.f5.com/s/articles/the101-irules-101-events-amp-priorities
 
- Lucilius_223799Jul 19, 2016
Nimbostratus
Alright, that sounds like a good idea. I'll make an iRule with a priority that overrules the others on default. Is it possible however to make the iRule do so for multiple different websites that are running from the virtual server?
Let's say some are called abc, xyz and def etc. all redirect to maintenance.com without calling them all by name or do i have to call them all on by name?
- boneyardJul 19, 2016
MVP
as Yann points out if you just do the redirect line without an if { } then it will act on every request. no need to do it by name, unless you want to do it for only a couple of them.
- Lucilius_223799Jul 19, 2016
Nimbostratus
Then my question is answered! Thank you for everyone's help.
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