Am redirecting urls from a legacy site, which gets me to a url like this:
http://example.com/blog/01/detail
I would like to automatically remove the leading zeros from these urls (seems it doesn't matter how many zeros are in there 001
0001
000001
work) so that the page redirects to:
http://example.com/blog/1/detail
Is there a simple way to go about doing this in django ? (Or, via the .htaccess
redirect?)
URL code:
url(u'^blog/(?P<object_id>\d+)/detail$',
list_detail.object_detail,
{ 'queryset' : Blog.objects.all(), },
name='blog_detail',)
.htaccess (being redirected):
RewriteRule ^blog-([0-9]+) http://example.com/blog/$1 [R=301]
Would I need some middleware or is there an easy way to do this in the urls.py
file ?