Forum Discussion
DanO_100877
Nimbostratus
Mar 25, 2008Does execution halt after http::respond?
I'm trying to set up a series of rules for an upcoming transition of our site to a WCM with wildly different URLs from our old site. What I want to know is if the code stops executing after an http::respond is issued or if I need to explicitly exit the code to prevent it from trying to match any further rules. Here's an example code block:
foreach item $::redirect_ids {
if {$item == $page_id} then {
HTTP::respond 301 Location "http://$::base_hostname/site/en/us/$item"
}
}
HTTP::respond 301 Location "http://$::base_hostname/site/us/en/home/Global/We-Have-Redesigned-the-Site.html?cid=ErrorPage$page_id"
So, I'll have a list of pageids that we want to send to these new pages, but if it doesn't match any of those explicitly redirected ids, just send it to a default error page. If page_id 12345 is in the list, it should do a 301 redirect to our base_hostname, plus the middle URI stuff, plus that same page id as a fake directory. But once it has done that, I don't want it to hit the next line of code that is the default behavior for no matches. Do I need an exit after the http::respond or is that implicit in the respond execution?
Thanks,
Dan O
- The_Bhattman
Nimbostratus
If I understand you correct you want redirect if all http requests hit a know page_ID. If the page is part of your list you want redirect to an errorpage.foreach item $::redirect_ids { if { $item == $page_id } {HTTP::redirect "http://$::base_hostname/site/en/us/$item" } else {HTTP::redirect "http://$::base_hostname/site/us/en/home/Global/We-Have-Redesigned-the-Site.html?cid=ErrorPage$page_id" } }
- DanO_100877
Nimbostratus
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
- The_Bhattman
Nimbostratus
Glad to indirectly help you :-)
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