Forum Discussion
PacketHead_4009
Nimbostratus
Nov 04, 2010URI Redirect to main page
Hello,
I have a few iRules that do something similar to what I am looking for but not specifically what I am trying to do.
Basically I have a VIP for www.mysite.com. I have some old links that no longer work due to content change and upgrades but users have these links stored as favorties and in their system (i.e. www.mysite.com/user/manpage/home and www.mysite.com/admins/manpage/tools )
I want to create an iRule to redirect the users back to the main page if they have any of the URLs listed above. This seems simple enough with some if and else statements but I'm still new to iRule coding.
Any help would be appreciated!
- James
6 Replies
- George_Watkins_Historic F5 AccountHi James,
Something like this would probably do the trick:when HTTP_REQUEST { switch -glob [HTTP::path] { "/user/manpage/home/*" - "/admins/manpage/tools/*" - default { HTTP::redirect http://www.mysite.com } } }
Add and remove more paths and/or wildcards as necessary.
-George - PacketHead_4009
Nimbostratus
Hello George,
That looks like it should work. Now my other question. How can I stack these so that I have the URL "/admins/manpage/tools*" redirect to www.mysite.com/tools/new instead of the main site ? Can I stack it on the same iRuel somehow?
Thanks,
James - George_Watkins_Historic F5 AccountHi James,
The hyphens just say, "drop through to the next action." In this case it will drop all the way through to the default action, which is redirect to http://www.mysite.com. If you want to redirect on a specific URL, do this:when HTTP_REQUEST { switch -glob [HTTP::path] { "/admins/manpage/tools/*" { HTTP::redirect http://www.mysite.com/tools/new } "/user/manpage/home/*" - default { HTTP::redirect http://www.mysite.com } } }
Does that help?
-George - PacketHead_4009
Nimbostratus
Ok, let me take a step back. Looks like it is looping. So my main VIP/site is www.mysite.com
If I just do your basic URL as follows:
when HTTP_REQUEST {
switch -glob [HTTP::path] {
"/user/manpage/home/homesite.htm" -
default {
HTTP::redirect http://www.mysite.com
}
}
}
I get a browser error stating the page it going in a redirect loop. Please note that I changed the "/user/manpage/home/*" wildcard to a specific file in that directory if that makes a difference.
Any ideas? If I redirect it to a page other than the VIP/site, the redirect works fine. - George_Watkins_Historic F5 AccountI don't know why you are getting stuck in a redirect loop. My first guess would be that you are also redirecting at the web server. The iRule itself should not be putting you in a redirect loop.
-George - hoolio
Cirrostratus
If /user/manpage/home/homesite.htm references any other objects like css, images, etc, then you'll get a loop. At a minimum, you'd want to allow (not redirect) that URI and any URIs it references.
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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