redirect 301

38 views
Skip to first unread message

alex bodnaru

unread,
Jul 24, 2012, 8:21:00 AM7/24/12
to turbo...@googlegroups.com

hello friends,

for an application migrated from asp, i have an asp like controller, that
redirects to the new urls.

i'm just asking, how could i set the redirect 301 code?

should i set this in the arguments to the new controller, and if found there,
should the appropriate headers be set?

how would you do it?

thanks in advance,
alex

Carlos Daniel Ruvalcaba Valenzuela

unread,
Jul 24, 2012, 9:38:50 AM7/24/12
to turbo...@googlegroups.com
Try rising HTTPMovedPermanently exception, which can be imported from
webob.exc, take for example the following example:

from webob.exc import HTTPMovedPermanently

class RootController(BaseController):
@expose()
def old_url(self):
raise HTTPMovedPermanently(location="/")

As you can see HTTPMovedPermanently accepts the param location to tell
it where to redirect the client. Be sure to raise as an exception and
not just return it.

Regards,
Carlos Daniel Ruvalcaba Valenzuela

alex bodnaru

unread,
Jul 25, 2012, 6:13:29 AM7/25/12
to turbo...@googlegroups.com

thanks a lot carlos,

it worked like a charm :) .

alex
Reply all
Reply to author
Forward
0 new messages