Forum Discussion
Traffic Redirection
Sorry if this is a very greenhorn question but i'm just getting started with the irules in the F5 and wanted to know what the script would look like for the redirect i'm going for. I want to do a URL redirect from https://irule.sample.com to https://irule.newsample.com/launcher/irule. How would I go about doing this? Again, I an very new at this and any help would be appreciate. Thank you.
3 Replies
- Stanislas_Piro2
Cumulonimbus
You can try this
when HTTP_REQUEST { if {([HTTP::host] equals "irule.sample.com") && ([HTTP::uri] equals "/")} { HTTP::redirect "https://irule.newsample.com/launcher/irule" } } - Hannes_Rapp
Nimbostratus
when HTTP_REQUEST { if { ([HTTP::host] == "irule.sample.com") && ([HTTP::path] == "/" )}{ HTTP::respond 302 location "https://irule.newsample.com/launcher/irule" Invokes a temporary 302 redirect, replace with 301 if you want permanent instead. event disable Recommended function, if you use other iRules that also utilize the HTTP_REQUEST event. TCP::close Recommended because it resolves the issue with redirect not functioning from the second web-browser tab if already invoked more than once. (issue applies to Chrome and HTTP/1.1). } }Test it out. I've added some comments to help you understand the lines. You will need to apply the iRule to your TCP/443 port listener Virtual Server. Also for the iRule to work, your VS must have a clientside SSL profile configured as well as a HTTP profile.
- Pragathishakar1
Nimbostratus
You can use this one. To know more please refer the Dev Central page.
when HTTP_REQUEST { if { [string tolower [HTTP::uri]] equals "/"} { HTTP::redirect "https://irule.newsample.com/launcher/irule" return } }
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