Forum OpenACS Q&A: Re: Best way to do HTTP 3xx Redirections?

Collapse
Posted by Michael Bluett on
I have more information to add to this :- Google likes 301 redirects (permanent redirects), so I have looked up how to do 301 redirects (ad_returnredirect simply returns a 302 redirect). The aolserver manual suggests this:
Using ns_respond, it's easy to do an HTTP redirect: 
set headers [ns_set new myheaders]
ns_set put $headers location http://www.aolserver.com
ns_respond -status 302 -type text/plain \
    -string "redirection" -headers $headers
By changing the 302 to 301 this should work fine. This is primarily to replace existing Apache "RedirectPermanent/Redirect permanent" directives.
Collapse
Posted by Andrew Piskorski on
Hm, this 301 redirect sounds like a good feature to have. ns_returnredirect (which is what ad_returnredirect calls) always does a 302 though. Sounds like a good idea to either add a switch to let it optionally do a 301 instead, or add a new command, ns_returnmoved or ns_returnredirectpermanent or something like that. Should be pretty easy to change the AOLserver Ns_ConnReturnRedirect C function to make it happen.

So, I just filed a feature request for that on SourceForge

Of course, without an extension to the AOLserver API like that, you should be able to always just do it with a Tcl proc like you said.