Skip to content

Commit 321da6c

Browse files
Fix error_page for versioned doc subdirectory URLs (#640)
1 parent 5448367 commit 321da6c

File tree

11 files changed

+70
-6
lines changed

11 files changed

+70
-6
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ location ~ ^/((2|3)(\.[0-9]+)?|dev)/\w+/[\d\w\.]+(?!\.html)$ {
182182
if (-f "${request_filename}.html") {
183183
return 301 https://$host:$request_uri.html;
184184
}
185+
error_page 404 /$1/404.html;
185186
add_header Surrogate-Key en/$1 always;
186187
}
187188

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.14 404
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3 404
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dev 404
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fr/3.14 404
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pl/3 404
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
zh-cn/dev 404

tests/docs-redirects/nginx.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
server {
22
listen 10000;
3+
root /srv/docroot;
4+
autoindex on;
35
include docs-redirects.conf;
46
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
GET {{host}}/3.14/not-a-file
2+
HTTP 404
3+
[Asserts]
4+
body contains "3.14 404"
5+
6+
GET {{host}}/3/not-a-file.html
7+
HTTP 404
8+
[Asserts]
9+
body contains "3 404"
10+
11+
GET {{host}}/3.14/whatsnew/3.1t4
12+
HTTP 404
13+
[Asserts]
14+
body contains "3.14 404"
15+
16+
GET {{host}}/3.14/library/not-a-file
17+
HTTP 404
18+
[Asserts]
19+
body contains "3.14 404"
20+
21+
GET {{host}}/3.14/library/notafile.html
22+
HTTP 404
23+
[Asserts]
24+
body contains "3.14 404"
25+
26+
GET {{host}}/3/whatsnew/not-a-file
27+
HTTP 404
28+
[Asserts]
29+
body contains "3 404"
30+
31+
GET {{host}}/fr/3.14/not-a-file
32+
HTTP 404
33+
[Asserts]
34+
body contains "fr/3.14 404"
35+
36+
GET {{host}}/fr/3.14/not-a-dir/not-a-file
37+
HTTP 404
38+
[Asserts]
39+
body contains "fr/3.14 404"
40+
41+
GET {{host}}/pl/3/not-a-dir/not-a-file.html
42+
HTTP 404
43+
[Asserts]
44+
body contains "pl/3 404"
45+
46+
GET {{host}}/pl/3/not-a-dir/not-a-dir/not-a-file.html
47+
HTTP 404
48+
[Asserts]
49+
body contains "pl/3 404"
50+
51+
GET {{host}}/pl/3/library/notafile.html
52+
HTTP 404
53+
[Asserts]
54+
body contains "pl/3 404"

tests/docs-redirects/specs/surrogate-key.hurl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Basic cases
44

55
GET {{host}}/3/
6-
HTTP 404
6+
HTTP 200
77
[Asserts]
88
header "Surrogate-Key" == "en/3"
99

@@ -30,7 +30,7 @@ HTTP 404
3030
header "Surrogate-Key" == "en/2"
3131

3232
GET {{host}}/dev/
33-
HTTP 404
33+
HTTP 200
3434
[Asserts]
3535
header "Surrogate-Key" == "en/dev"
3636

@@ -284,7 +284,7 @@ HTTP 404
284284
header "Surrogate-Key" == "en/3.13"
285285

286286
GET {{host}}/3.14/
287-
HTTP 404
287+
HTTP 200
288288
[Asserts]
289289
header "Surrogate-Key" == "en/3.14"
290290

@@ -396,7 +396,7 @@ HTTP 404
396396
header "Surrogate-Key" == "fr/3"
397397

398398
GET {{host}}/fr/3.14/
399-
HTTP 404
399+
HTTP 200
400400
[Asserts]
401401
header "Surrogate-Key" == "fr/3.14"
402402

@@ -536,7 +536,7 @@ HTTP 404
536536
header "Surrogate-Key" == "ko/dev"
537537

538538
GET {{host}}/pl/3/
539-
HTTP 404
539+
HTTP 200
540540
[Asserts]
541541
header "Surrogate-Key" == "pl/3"
542542

@@ -736,7 +736,7 @@ HTTP 404
736736
header "Surrogate-Key" == "zh-cn/3.14"
737737

738738
GET {{host}}/zh-cn/dev/
739-
HTTP 404
739+
HTTP 200
740740
[Asserts]
741741
header "Surrogate-Key" == "zh-cn/dev"
742742

0 commit comments

Comments
 (0)