1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | from django.views.generic.simple import redirect_to
urlpatterns = patterns('',
# ...your project's patterns...
)
# Your old/new URL tuples -- examples
redirects = (
('^kawasaki/zx750f', '/bikes/kawasaki/zx750f/'), # Matching a literal URL
('^gear/[0-9]+/$', '/gear/'), # Ignoring part of the matched URL
('^foo/(?P<id>\d+)/$', '/bar/%(id)s/'), # Oooh, parameter capture!
)
for oldurl, newurl in redirects:
urlpatterns += patterns('', (oldurl, redirect_to, {'url': newurl}))
|
More like this
- Mini issue tracker by pbx 6 years, 2 months ago
- RegEx redirect fallback middleware by bowdengm 10 months, 2 weeks ago
- Rails Style Controller by julan 4 years, 6 months ago
- View Permission Decorator Helper by jgeewax 4 years, 10 months ago
- django subdomain support for both resolve and reverse. by puppy 2 years, 11 months ago
Comments