Catching parameters in URI, rewriting.
We are migrating to a new forum system, and need to be able to support users who may have certain threads bookmarked. The topics and threads have all been imported into the new forum.
I have a simple rule already working in order to catch the main topics:
http://oldforumsite.com/forum_topics.asp?FID=37&title=asdf
and rewrite to:
http://newforumsite.com/default.aspx?g=topics&f=37
I need to be able to support individual forum threads as well. We need to catch forum_topics.asp, and forum_posts.asp, and rewrite them to topics and posts.
Old Forum Topics:
http://oldforumsite.com/forum_topics.asp?FID=37&title=asd
Old Forum Posts
http://oldforumsite.com/forum_posts.asp?TID=57521&FID=37&title=asdf-asd-asd-asd
New Forum Topics
http://newforumsite.com/default.aspx?g=topics&f=37
New Forum Posts
http://newforumsite.com/default.aspx?g=posts&t=57521
I have the following iRule in place, which checks the URI to see if it contains FID, or TID, and redirects properly to the corresponding topic in the new forum system. What I am having difficulty figuring out is how to catch a URI if it has either FID, TID, or both FID and TID, and then rewrite. You'll notice above, for individual forum posts, there is both a TID and an FID.
If the URI contains FID with parameters, then it needs to rewrite to the New Forum Topic. If the URI contains a TID AND an FID with parameters, then it needs to rewrite to to the New Forum Post.
Here's what I have so far - this works for rewriting to the correct forum topics, which displays a listing of individual forum posts. Can anyone help me with next steps?
when HTTP_REQUEST {
if { [HTTP::uri] contains "FID" } {
HTTP::redirect "http://newforumsite.com/default.aspx?g=topics&f=[URI::query [HTTP::uri] FID]"
}
if { [HTTP::uri] contains "TID" } {
HTTP::redirect "http://newforumsite.com/default.aspx?g=posts&t=[URI::query [HTTP::uri] TID]"
}
}