Skip to content

Instantly share code, notes, and snippets.

@igniteflow
Created December 2, 2011 10:10
Show Gist options
  • Select an option

  • Save igniteflow/1422656 to your computer and use it in GitHub Desktop.

Select an option

Save igniteflow/1422656 to your computer and use it in GitHub Desktop.
Super simple redirect for a Django app
'''
A quick and dirty redirect, preserving params and path info
'''
# urls.py
urlpatterns = patterns('',
(r'', 'tce.views.redirect_req'),
)
# views.py
def redirect_req(request):
link = 'https://yourdomain.com/'
if request.META['PATH_INFO']:
link += '%s' % request.META['PATH_INFO']
if request.META['QUERY_STRING']:
link += '?%s' % request.META['QUERY_STRING']
return redirect(link)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment