Skip to content

Commit 95304aa

Browse files
authored
Redirect cleanup (#2378)
* Revert "Redirect legacy community page (#2319)" This reverts commit f88599b. * move community-landing redirect to nginx * move remainging RedirectViews to nginx * match intended recirect from community-landing pr
1 parent a7f830a commit 95304aa

File tree

3 files changed

+25
-18
lines changed

3 files changed

+25
-18
lines changed

Diff for: blogs/tests/test_views.py

-9
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,3 @@ def test_blog_home(self):
2727

2828
latest = BlogEntry.objects.latest()
2929
self.assertEqual(resp.context['latest_entry'], latest)
30-
31-
def test_blog_redirects(self):
32-
"""
33-
Test that when '/blog/' is hit, it redirects '/blogs/'
34-
"""
35-
response = self.client.get('/blog/')
36-
self.assertRedirects(response,
37-
'/blogs/',
38-
status_code=301)

Diff for: config/nginx.conf.erb

+24
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ http {
8484
return 301 https://www.python.org/psf;
8585
}
8686

87+
location ~ ^/community-landing/?(.*)$ {
88+
return 301 https://www.python.org/community/;
89+
}
90+
8791
location /doc/Summary {
8892
return 301 http://legacy.python.org/doc/intros/summary;
8993
}
@@ -204,6 +208,22 @@ http {
204208
return 301 https://www.python.org/download/windows/;
205209
}
206210

211+
location /download/ {
212+
return 301 https://www.python.org/downloads/;
213+
}
214+
215+
location /download/source/ {
216+
return 301 https://www.python.org/downloads/source/;
217+
}
218+
219+
location /download/mac/ {
220+
return 301 https://www.python.org/downloads/macos/;
221+
}
222+
223+
location /download/windows/ {
224+
return 301 https://www.python.org/downloads/windows/;
225+
}
226+
207227
location /Mirrors.html {
208228
return 301 https://www.python.org/mirrors/;
209229
}
@@ -292,6 +312,10 @@ http {
292312
return 302 /blogs/;
293313
}
294314

315+
location /blog/ {
316+
return 301 https://python.org/blogs/;
317+
}
318+
295319
location /static/ {
296320
alias /app/static-root/;
297321
add_header Cache-Control "max-age=604800, public"; # 604800 is 7 days

Diff for: pydotorg/urls.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
44
from django.conf.urls.static import static
55
from django.urls import path, re_path
6-
from django.views.generic.base import TemplateView, RedirectView
6+
from django.views.generic.base import TemplateView
77
from django.conf import settings
88

99
from cms.views import custom_404
@@ -24,18 +24,11 @@
2424
# python section landing pages
2525
path('about/', TemplateView.as_view(template_name="python/about.html"), name='about'),
2626

27-
# Redirect old download links to new downloads pages
28-
path('download/', RedirectView.as_view(url='https://www.python.org/downloads/', permanent=True)),
29-
path('download/source/', RedirectView.as_view(url='https://www.python.org/downloads/source/', permanent=True)),
30-
path('download/mac/', RedirectView.as_view(url='https://www.python.org/downloads/macos/', permanent=True)),
31-
path('download/windows/', RedirectView.as_view(url='https://www.python.org/downloads/windows/', permanent=True)),
32-
3327
# duplicated downloads to getit to bypass China's firewall. See
3428
# https://github.com/python/pythondotorg/issues/427 for more info.
3529
path('getit/', include('downloads.urls', namespace='getit')),
3630
path('downloads/', include('downloads.urls', namespace='download')),
3731
path('doc/', views.DocumentationIndexView.as_view(), name='documentation'),
38-
path('blog/', RedirectView.as_view(url='/blogs/', permanent=True)),
3932
path('blogs/', include('blogs.urls')),
4033
path('inner/', TemplateView.as_view(template_name="python/inner.html"), name='inner'),
4134

@@ -54,7 +47,6 @@
5447
name='account_change_password'),
5548
path('accounts/', include('allauth.urls')),
5649
path('box/', include('boxes.urls')),
57-
re_path(r'^community-landing(/.*)?$', RedirectView.as_view(url='/community/', permanent=True)),
5850
path('community/', include('community.urls', namespace='community')),
5951
path('community/microbit/', TemplateView.as_view(template_name="community/microbit.html"), name='microbit'),
6052
path('events/', include('events.urls', namespace='events')),

0 commit comments

Comments
 (0)