Forum Discussion
Joe_105988
Nimbostratus
Mar 03, 2008Question on how to create a HTTP redirect rule
I am new to creating iRules and need to create one that redirects either of 2 urls (for both http or https) to one url (https).
Any help would be appreciated.
Thanks!
4 Replies
- Nicolas_Menant
Employee
Hi,
You should have a look at all the previous posts.
Just on the main page of this forum you have this question which is asked several times.
You should be able to find what you're looking
example:
Click here
Click here
Click here - Joe_105988
Nimbostratus
I do not see an instance where there are multiple URLs that need to be directed to 1. Can I use multiple 'When' statements in the same iRule? If so, I can see how this can be done. - Nicolas_Menant
Employee
You can use multiple when yes.
Otherwise to match multiple URIs you can use something like switch.
An extract from one of the link i sent you
when HTTP_REQUEST {
switch -glob [HTTP::URI] {
"/" { HTTP::redirect "https://[HTTP::host]/PortalWAR/appmanager/portal/home" }
"/blah/blah*" { HTTP::redirect "https://[HTTP::host]/[HTTP::uri]" }
"*blah" { HTTP::redirect "https://[HTTP::host]/[HTTP::uri]" }
"blah*" { HTTP::redirect "https://[HTTP::host]/[HTTP::uri]" }
"b?ah" { HTTP::redirect "https://[HTTP::host]/[HTTP::uri]" }
}
}
}
Here all those URI will be redirected to something else.
Here you have an example with some regexp. - The_Bhattman
Nimbostratus
If you cut and paste the example above, then remove the extra "}" brace at the end. That should allow the code to run.
-CB
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects
