Skip to content

Commit 36994b9

Browse files
authored
Fix a few d.p.o redirect rules (#506)
* Split d.p.o redirects to a new config file * Add header note * Add Hurl specs * Add CI testing * Fix the `genindex` redirect * Restrict the ftp redirect to ``/ftp/python/doc`` * Require a full match for the py3k redirect
1 parent a851c6d commit 36994b9

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

salt/docs/config/nginx.docs-redirects.conf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ location ~ \.(pdf|zip|epub|bz2)$ {
1818
}
1919

2020
# Some doc download pages link to docs.python.org/ftp instead of www.python.org/ftp.
21-
location ^~ /ftp/ {
21+
location ^~ /ftp/python/doc {
2222
return 301 https://www.python.org$request_uri;
2323
}
2424

25-
location ~ /py3k(.*)$ {
25+
# Py3k is Python 3
26+
location ~ ^/py3k(.*)$ {
2627
return 301 https://$host/3$1;
2728
}
2829

@@ -169,7 +170,7 @@ location = /documenting/building.html {
169170
location ~ ^/((archives|c-api|distutils|extending|faq|howto|install|library|reference|tutorial|using|whatsnew|_images|_sources|_static)(/.*)?)$ {
170171
return 301 https://$host/3/$1;
171172
}
172-
location ~ ^/(about|bugs|contents|copyright|download|genindex.*|glossary|index|license|py-modindex|search)(.html)?$ {
173+
location ~ ^/(about|bugs|contents|copyright|download|genindex(-[^.]+)?|glossary|index|license|py-modindex|search)(.html)?$ {
173174
return 301 https://$host/3/$1.html;
174175
}
175176
location ~ ^/(searchindex.js|objects.inv)$ {

tests/docs-redirects/specs/top-level-files.hurl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ header "Location" == "https://localhost/3/download.html"
5353
GET {{host}}/genindex.html
5454
HTTP 301
5555
[Asserts]
56-
header "Location" == "https://localhost/3/genindex.html.html"
56+
header "Location" == "https://localhost/3/genindex.html"
5757

5858
GET {{host}}/genindex
5959
HTTP 301
@@ -63,7 +63,7 @@ header "Location" == "https://localhost/3/genindex.html"
6363
GET {{host}}/genindex-_.html
6464
HTTP 301
6565
[Asserts]
66-
header "Location" == "https://localhost/3/genindex-_.html.html"
66+
header "Location" == "https://localhost/3/genindex-_.html"
6767

6868
GET {{host}}/genindex-_
6969
HTTP 301
@@ -73,7 +73,7 @@ header "Location" == "https://localhost/3/genindex-_.html"
7373
GET {{host}}/genindex-A.html
7474
HTTP 301
7575
[Asserts]
76-
header "Location" == "https://localhost/3/genindex-A.html.html"
76+
header "Location" == "https://localhost/3/genindex-A.html"
7777

7878
GET {{host}}/genindex-A
7979
HTTP 301
@@ -83,7 +83,7 @@ header "Location" == "https://localhost/3/genindex-A.html"
8383
GET {{host}}/genindex-Symbols.html
8484
HTTP 301
8585
[Asserts]
86-
header "Location" == "https://localhost/3/genindex-Symbols.html.html"
86+
header "Location" == "https://localhost/3/genindex-Symbols.html"
8787

8888
GET {{host}}/genindex-Symbols
8989
HTTP 301

0 commit comments

Comments
 (0)