Forum Discussion
iRule - URL Redirect
Hello,
One of our sites has two virtual servers, one for port 80 and another for 443. The port 80 virtual server currently has a https redirect iRule attached sending all port 80 traffic to 443. The business is asking if I can do a couple of url redirects. For example, sending all www.123.com/games requests to www.123.com/test1 and all www.123.com/live to www.123.com/test2. Can you please provide an iRule I can use to fulfill this request? Can I use just one iRule to do multiple url redirects? and where do I attach the iRule? on the port 443 virtual server.
Thank you for your help!
2 Replies
- Brad_Parker
Cirrus
Yes you can do this with one iRule. It could look something like this:
when HTTP_REQUEST { switch -glob [string tolower [HTTP::path]] { "/games*" { HTTP::respond 301 noserver Location "https://[HTTP::host]/test1" } "/live*" { HTTP::respond 301 noserver Location "https://[HTTP::host]/test2" } default { return } } }Also, if you are using BigIP v11.4+ you can also consider using Local Traffic Policies to redirect traffic based on HTTP::path.
https://support.f5.com/kb/en-us/solutions/public/15000/000/sol15085.html
- sysadmin_2015_2
Nimbostratus
Hello,
Thank you for your reply! I have applied the above iRule and it appears to be working.
Thank you again for your 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