1: I donβt think it makes sense to use a canonical tag if there are 301 anyway.
Imagine a scenario in which you change the URL from /q/111/hello-world to /q/111/foobar . Engines do not assume that they are equal unless they visit the original url with a canonical tag on it pointing to /q/111/foobar (which is usually because it is now 301, tearing off any evidence of a link between pages).
2: I would do it straightforwardly. Define a non-unique slug field and compare with the captured URL in your verbose view.
# models class MyModel(models.Model): # ... non_unique_slug = models.SlugField() def get_absolute_url(self): return "/questions/%s/%s" % (self.id, self.non_unique_slug) # urls r'^questions/(?P<id>\d+)/(?P<slug>[\w-]+)/$' # views def my_view(request, id, slug): page = Page.objects.get(id=id) if not slug == page.slug: return http.HttpResponsePermanentRedirect(page.get_absolute_url()) # render page return direct_to_template(request, "foobar.html", {'page': page})
Yuji 'Tomita' Tomita
source share