Forum Discussion
URL redirect to multiple paths
Hi. I have a request for a host name (example.123.com) that I need to redirect to 2 different paths. If a user types https://example.123.com I need to redirect it to https://example.123.com/loginpage1. This part I did with a traffic policy rule. Using the same VIP if someone types in https://example.123.com/loginpage2 it needs to go to the same server only to a different login page.
This what I'm using for a Policy Rule Conditions Operand Event Selector Negate Condition Values http-host Request all equals example.123.com http-uri Request path not contain /loginpage1/
Actions Target Event Actions Parameters http-uri Request Replace Path /loginpage1/
If I browse to the host and add /loginpage2 as the path it follows the rule and sends me to /loginpage1/. So my questions are 1.Can this be done in one or more policy rules and I'm just not doing it right or 2.Should it be done with an iRule and I am not good with irules.
Any feedback is appreciated
1 Reply
- Vijay_E
Cirrus
I haven't worked much with policies but iRule should be able to help you out. If you are looking to redirect, you should be able to use something like this:
when HTTP_REQUEST { if { ([HTTP::host] eq "example.123.com") } { if { ([HTTP::uri] eq "/") or ([HTTP::uri] eq "/loginpage2") } { HTTP::respond 301 Location "https://example.123.com/loginpage1" } } }If you are just looking to replace the URI and send it directly to server instead of a redirect:
when HTTP_REQUEST { if { ([HTTP::host] eq "example.123.com") } { if { ([HTTP::uri] eq "/") or ([HTTP::uri] eq "/loginpage2") } { HTTP::uri /loginpage1 } } }
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
