-
Notifications
You must be signed in to change notification settings - Fork 679
Bug 1362438: additional redirects from SCL3 Apache to Django #4231
Conversation
I'm not sure if the Travis errors are related to this PR. |
kuma/redirects/redirects.py
Outdated
redirect( | ||
r'^(?P<pre>[\w\-]*)/HTML5$', | ||
'/{pre}/docs/HTML/HTML5', | ||
re_flags='i', prepend_locale=False, permanent=True), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern is causing the Kuma test failure. I'll need to look closer at Kuma and commit history to decide which needs to bend.
OK, here's what's happening. The failing test is requesting this path:
The
This is because So, the redirect pattern uses the rule:
to redirect to:
breaking the test, which is trying to detect MindTouch URLs like In any case, URL patterns that are trying to detect locales (this one and a few others) need to lean on I think I own this PR now, having made @metadave wait over 2 months for me to figure it out. |
39d8cd2
to
175321b
Compare
Add helper function to explicitly set locale_prefix and prepend_locale to False for "regular" redirects, to avoid matching on non-locale prefixes. Add helper function locale_redirect to set locale_prefix to True, and default prepend_locale to True. Adjust locale redirect patterns to rely on locale matching in redirect_urls library. The /Learn topic has moved to /docs/Learn, but this redirect is enforced in Apache rules. Adding a TODO to change the redirect after AWS move. Adjusted some test patterns to use valid locales, so that tests will pass against Apache in SCL3 and locally.
175321b
to
17ec129
Compare
Codecov Report
@@ Coverage Diff @@
## master #4231 +/- ##
==========================================
+ Coverage 88.32% 88.33% +<.01%
==========================================
Files 163 163
Lines 10229 10233 +4
Branches 1420 1420
==========================================
+ Hits 9035 9039 +4
Misses 968 968
Partials 226 226
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Django tests are passing, and the redirect tests pass against Apache/SCL3 and just Django. Thanks, @metadave!
As part of mozmeao/infra#436, I took a look at what's left from the Apache config.
These files are periodically generated, and accessed by Google and others to see what is new. We'll need to serve these from Django instead. If we move
This must have been the way to load pages in the MediaWiki/DekiWiki days. I looked at the requests and they are roughly:
I don't see any reason to handle these requests, and they should return 404s
This is tracked in bug 962148. This rule serves up the duplicate content under a different URL, and instead we want a permanent redirect.
This is the Apache alias for the Django modwsgi handler, and it not needed in AWS. To determine the impact of these rules, I looked the the Apache access logs on developer1, which is one of six servers for developer.mozilla.org, developer.cdn.mozilla.net, and mozillademos.org.
Update 1: We do have recent changes feeds. I still think we should 404 the requests to the legacy feeds, rather than redirect them to "Create a New Page". |
source:
https://github.com/mozilla/kuma/blob/master/configs/htaccess
The remaining rules to address from htaccess are in this gist for now.
[L]
in this file) will most likely need to be handled by Whitenoise or some other method:robots.txt
via a template to change content based on dev/stage/prod:en-US
hardcoded either haveen-US
directly in the redirect rule, or use this prefix regex to match locale:^(?P<pre>\w{2,3}(?:-\w{2})?/)?