Wiadomość napisana w dniu 2009-09-25, o godz. 10:16, przez mike: > > Hi. Im migrating from an old PHP piece of junk to Django (hooray) and > this client is very insistent on maintaining all of his old PHP-based > URLs, which will be 301 redirected so as to not lose SEO. As there > are 1000s of these links, mod_rewrite might not be the best solution, > especially since we've got HttpResponsePermanentRedirect > > Old Link: > www.somesite.com/app/?product=1234 > > New Link: > www.somesite.com/app/slugged-text > > Urls.py Line: > (r'^app/\?product=(?P<oldnumber>)$','site.app.views.xxx'), > > Now the problem is, Django wont match an escaped starting question > mark (?).... or am I missing something? (it works fine if I were to > exclude the ?, as in "product=1234".... but is a pre-processed url via > "re.sub" possible?)
GET parameters are not matched by patterns. I'd catch all these with single view and return redirects, like: def my_view(request): product_id = request.GET['product'] product = Product.objects.get(pk=product_id) return HttpResponseRedirect(product.get_absolute_url(), permanent=True) And that's all. -- Artificial intelligence stands no chance against natural stupidity Jarek Zgoda, R&D, Redefine jarek.zg...@redefine.pl --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---