Forum Discussion
DanO_100877
Mar 26, 2008Nimbostratus
Thanks for the suggestion. That likely wouldn't work properly, however, since the else clause would execute the first time the if clause failed to match, which would almost always be the first iteration of the loop. However, it would work if I just assign a variable in the loop and then redirect to the variable after the loop, so you did give me an idea. Here's what it would look like:
set this_redirect "http://$::base_hostname/site/us/en/home/Global/We-Have-Redesigned-the-Site.html?cid=ErrorPage$page_id"
foreach item $::redirect_ids {
if { $item == $page_id } { set this_redirect "http://$::base_hostname/site/en/us/$item" }
}
HTTP::respond 301 Location $this_redirect
So, you assign the default value prior to the loop and then if any iteration of the loop matches, it re-assigns the new value to the variable. The else clause isn't needed because once you get a match and the value is assigned, the rest of the list can iterate and nothing will happen.
Additionally, isn't HTTP::redirect actually a 302(temporary), rather than a 301(permanent)? We need it to be permanent to ensure proper indexing by Google, etc.
Thanks,
Dan O