Created
December 2, 2011 10:10
-
-
Save igniteflow/1422656 to your computer and use it in GitHub Desktop.
Super simple redirect for a Django app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| 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