0

我回来征求意见。我有一个需要 SEO 帮助的网站,并被要求投放 301 重定向广告。这个站点是我收集的从 php 到 django 的转换。现在我得到了一个大约 700 个 URL 的 csv,基本上都是

http://www.rhodeislandrow.com/floor-plans/search/?sort=price_desc&floor=---&max_price=1304&min_price=0&csrfmiddlewaretoken=3688d94aa3454e592f016d032a126328&availability=1322629596

好吧,我在研究后决定我需要做一个 from django.views.generic.simple import redirect_来解决。但是玩这个,它不起作用。任何人都可以帮助我指导使用什么吗?我在这里阅读了文档:

https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpResponsePermanentRedirect

这是我的网址:

from django.conf.urls.defaults import patterns, include, url
from django.contrib import admin
from django.views.generic.simple import direct_to_template
from django.views.generic.simple import redirect_to
from main.sitemaps import sitemaps
from main.views import *
admin.autodiscover()



urlpatterns = patterns('',
    # Redirects from old site
    (r'^floor-plans/search/$', redirect_to, {'url': 'http://www.rhodeislandrow.com/floor-plans/'}),

    url(r'^admin/', include(admin.site.urls)),
    url(r'^subscribe/$', SubscribeView, name='subscribe'),
    url(r'^vaultware-template/$', VaultwareTemplateView.as_view()),

    url(r'^', include('stateful.urls')),
    url(r'^', include('cms.urls')),
    (r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),
    (r'^robots.txt$', include('robots.urls')),
)
4

1 回答 1

0

我想到了。因为我的 URL 没有以 /search/ 结尾,所以我需要添加通配符

(r'^floor-plans/search/.*$', redirect_to, {'url': 'http://www.rhodeislandrow.com/floor-plans/'}),

感谢您的回复,我将在未来的项目中使用重定向应用程序。

于 2012-07-26T19:51:42.927 回答