Forum Discussion
Troy_Atwood_942
Mar 08, 2011Nimbostratus
3 scenario 301 redirection problem
We are moving sections of our website to a new url structure and need to redirect only the sections that are moving.
Sounds like a job for IRules!
We have 3 scenarios that we need to intercept and 301 redirect.
First Scenario:
We have urls that have the following data in the url;
/docs/1201
/DOC-1201
The 1201 of course is the content identifier and we need to capture that data and pass it to this link. www..com/kredirect/doc/xxxx which will then 301 redirect to the new url. Is it possible to avoid a double redirect at the client?
Second Scenario:
This scenario does not require an extensive id look and only needs part of the url before the blog title replaced with the new location.
www..com/cm/comm/kn/blog/title-of-blog-post/?cs=xxxxx
301 to www..com/cm/blogs/newarea/title-of-blog-post/?cs=xxxxx
The last scenario:
We have several pages that will cease to exist and this rule needs to 301 redirect the urls to the same landing page.
www..com/cm/comm/kn?view=documents&numResults=25
www..com/cm/message/1406
www..com/cm/post!input.jspa?containerType=14&container=20130
www..com/cm/edit.jspa
www..com/cm/thread/
www..com/cm/comm/feeds/messages
www..com/cm/tags?containerType=44&container=2013
www..com/cm/pm-view.jspa?pmID=1022
www..com/cm/addressbook.jspa
301 to www..com/newlanding/
Can all of this be encapsulated in the same iRule?
Please point this iRule newbie in the right direction and any help would be greatly appreciated.
- hooleylistCirrostratusThis should all be possible within the same iRule. I would take a look at some of the native URI parsing commands to start with and avoid regexes if at all possible.
- Troy_Atwood_942NimbostratusHere is my first iRule made possible via all of the great examples I found in the forum.
- hooleylistCirrostratusHi Troy,
- Troy_Atwood_942NimbostratusIt is working well in the QA environment so we will see how the PROD rollout goes....;-) When I added the 4th case I thought about using a switch statement instead. Since I am ahead of the web developers I will probably give that a try since we will be moving more areas in the near future.
- Colin_Walker_12Historic F5 AccountSwitch is definitely more efficient. It's also, in my opinion, far more readable. We tend to encourage folks to go that route if they're comfortable with it. ;)
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