Forum Discussion
redirect for http and https VIPs
Hi, Need help to write an iRule to redirect traffic for http and https VIPs as:
HTTP VIP:
http://abc.com/ ----- redirect to http://abc.com/welcome
http://abc.com/welcome ----- redirect to http://abc.com/en/default/welcome
HTTPs VIP:
https://abc.com/ ----- redirect to https://abc.com/welcome
https://abc.com/welcome ----- redirect to https://abc.com/en/default/welcome
4 Replies
- PK_Bhatia
Nimbostratus
when HTTP_REQUEST { HTTP::respond 302 Location "https://[HTTP::host][HTTP::uri]" TCP::close }
- Kevin_Stewart
Employee
Would it make more sense to just redirect to "/en/default/welcome" if the URI is empty?
when HTTP_REQUEST { if { [HTTP::uri] equals "/" } { HTTP::redirect "http://[HTTP::host]/en/default/welcome" } }Replace "http://" with "https://" in the HTTPS VIP.
- Kevin_Stewart
Employee
Try this:
when HTTP_REQUEST { switch [string tolower [HTTP::uri]] { "/" - "/welcome" { HTTP::redirect "http://[HTTP::host]/en/default/welcome" } } }Assuming you're offloading the SSL for your HTTPS VIP traffic, the iRule should be the same except for the redirect scheme value (https:// vs. http://).
- Kevin_Stewart
Employee
Let's look at this from a flow, based on your original description.
1. user makes a request to "/" and is redirected to "/welcome" 2. user returns with a request to "/welcome" and is redirected to "/en/default/welcome"At what point do you want users to land on "/welcome" and not redirect?
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