diff --git a/blogs/tests/test_views.py b/blogs/tests/test_views.py index ee7df723b..5c6c5053f 100644 --- a/blogs/tests/test_views.py +++ b/blogs/tests/test_views.py @@ -27,12 +27,3 @@ def test_blog_home(self): latest = BlogEntry.objects.latest() self.assertEqual(resp.context['latest_entry'], latest) - - def test_blog_redirects(self): - """ - Test that when '/blog/' is hit, it redirects '/blogs/' - """ - response = self.client.get('/blog/') - self.assertRedirects(response, - '/blogs/', - status_code=301) diff --git a/config/nginx.conf.erb b/config/nginx.conf.erb index 527fdc0df..42bbf94cc 100644 --- a/config/nginx.conf.erb +++ b/config/nginx.conf.erb @@ -84,6 +84,10 @@ http { return 301 https://www.python.org/psf; } + location ~ ^/community-landing/?(.*)$ { + return 301 https://www.python.org/community/; + } + location /doc/Summary { return 301 http://legacy.python.org/doc/intros/summary; } @@ -204,6 +208,22 @@ http { return 301 https://www.python.org/download/windows/; } + location /download/ { + return 301 https://www.python.org/downloads/; + } + + location /download/source/ { + return 301 https://www.python.org/downloads/source/; + } + + location /download/mac/ { + return 301 https://www.python.org/downloads/macos/; + } + + location /download/windows/ { + return 301 https://www.python.org/downloads/windows/; + } + location /Mirrors.html { return 301 https://www.python.org/mirrors/; } @@ -292,6 +312,10 @@ http { return 302 /blogs/; } + location /blog/ { + return 301 https://python.org/blogs/; + } + location /static/ { alias /app/static-root/; add_header Cache-Control "max-age=604800, public"; # 604800 is 7 days diff --git a/pydotorg/urls.py b/pydotorg/urls.py index d1496dc03..c112b2e19 100644 --- a/pydotorg/urls.py +++ b/pydotorg/urls.py @@ -3,7 +3,7 @@ from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.conf.urls.static import static from django.urls import path, re_path -from django.views.generic.base import TemplateView, RedirectView +from django.views.generic.base import TemplateView from django.conf import settings from cms.views import custom_404 @@ -24,18 +24,11 @@ # python section landing pages path('about/', TemplateView.as_view(template_name="python/about.html"), name='about'), - # Redirect old download links to new downloads pages - path('download/', RedirectView.as_view(url='https://www.python.org/downloads/', permanent=True)), - path('download/source/', RedirectView.as_view(url='https://www.python.org/downloads/source/', permanent=True)), - path('download/mac/', RedirectView.as_view(url='https://www.python.org/downloads/macos/', permanent=True)), - path('download/windows/', RedirectView.as_view(url='https://www.python.org/downloads/windows/', permanent=True)), - # duplicated downloads to getit to bypass China's firewall. See # https://github.com/python/pythondotorg/issues/427 for more info. path('getit/', include('downloads.urls', namespace='getit')), path('downloads/', include('downloads.urls', namespace='download')), path('doc/', views.DocumentationIndexView.as_view(), name='documentation'), - path('blog/', RedirectView.as_view(url='/blogs/', permanent=True)), path('blogs/', include('blogs.urls')), path('inner/', TemplateView.as_view(template_name="python/inner.html"), name='inner'), @@ -54,7 +47,6 @@ name='account_change_password'), path('accounts/', include('allauth.urls')), path('box/', include('boxes.urls')), - re_path(r'^community-landing(/.*)?$', RedirectView.as_view(url='/community/', permanent=True)), path('community/', include('community.urls', namespace='community')), path('community/microbit/', TemplateView.as_view(template_name="community/microbit.html"), name='microbit'), path('events/', include('events.urls', namespace='events')),