forked from keymanapp/help.keyman.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.htaccess
169 lines (129 loc) · 5.3 KB
/
.htaccess
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# This file is used when running with Apache. Adapted from web.config.
# NOTE: this is not very well tested...
php_value include_path "/var/www/html/_includes:."
RewriteEngine on
# Redirect http://help.keyman.com to https://help.keyman.com,
# but only if on a live site (help.keyman.com) and not
# matching `/.well-known/(.*)$` (for Let's Encrypt)
<If "%{REQUEST_SCHEME} == 'http' && %{HTTP_HOST} == 'help.keyman.com' && %{REQUEST_URI} !~ m#^/.well-known/(.*)$#" >
Redirect "/" "https://help.keyman.com"
</If>
# versioning: these rules automatically redirect /foo/current-version to the
# newest version of the documentation under /foo, e.g. 13.0, /foo/13.0, and fall
# back to previous versions if no newer version is available. When we release a
# new version, we need to add in the rule for that version. 10.0 is the oldest
# version which falls under this pattern.
#
# The current-version:\d+.\d+ tag is used by the versioning script to get the
# current version (we can't simply use the newest because there may be alpha
# content on the site).
#
# When we add in the new version rule, remove the current- prefix from the
# older version. There are 3 places to insert the version number into the rule.
# # current-version:XX.0
# RewriteCond "%{DOCUMENT_ROOT}/$1/XX.0" -d
# RewriteRule "^(.+)/current-version(/.*|$)" "$1/XX.0$2"
# current-version:15.0
RewriteCond "%{DOCUMENT_ROOT}/$1/15.0" -d
RewriteRule "^(.+)/current-version(/.*|$)" "$1/15.0$2"
# version:14.0
RewriteCond "%{DOCUMENT_ROOT}/$1/14.0" -d
RewriteRule "^(.+)/current-version(/.*|$)" "$1/14.0$2"
# version:13.0
RewriteCond "%{DOCUMENT_ROOT}/$1/13.0" -d
RewriteRule "^(.+)/current-version(/.*|$)" "$1/13.0$2"
# version:12.0
RewriteCond "%{DOCUMENT_ROOT}/$1/12.0" -d
RewriteRule "^(.+)/current-version(/.*|$)" "$1/12.0$2"
# version:11.0
RewriteCond "%{DOCUMENT_ROOT}/$1/11.0" -d
RewriteRule "^(.+)/current-version(/.*|$)" "$1/11.0$2"
# version:10.0
RewriteCond "%{DOCUMENT_ROOT}/$1/10.0" -d
RewriteRule "^(.+)/current-version(/.*|$)" "$1/10.0$2"
# the following version fallbacks are for APIs such as /developer/cloud versions
# version:9.0
RewriteCond "%{DOCUMENT_ROOT}/$1/9.0" -d
RewriteRule "^(.+)/current-version(/.*|$)" "$1/9.0$2"
# version:8.0
RewriteCond "%{DOCUMENT_ROOT}/$1/8.0" -d
RewriteRule "^(.+)/current-version(/.*|$)" "$1/8.0$2"
# version:7.0
RewriteCond "%{DOCUMENT_ROOT}/$1/7.0" -d
RewriteRule "^(.+)/current-version(/.*|$)" "$1/7.0$2"
# version:6.0
RewriteCond "%{DOCUMENT_ROOT}/$1/6.0" -d
RewriteRule "^(.+)/current-version(/.*|$)" "$1/6.0$2"
# version:5.0
RewriteCond "%{DOCUMENT_ROOT}/$1/5.0" -d
RewriteRule "^(.+)/current-version(/.*|$)" "$1/5.0$2"
# version:4.0
RewriteCond "%{DOCUMENT_ROOT}/$1/4.0" -d
RewriteRule "^(.+)/current-version(/.*|$)" "$1/4.0$2"
# version:3.0
RewriteCond "%{DOCUMENT_ROOT}/$1/3.0" -d
RewriteRule "^(.+)/current-version(/.*|$)" "$1/3.0$2"
# version:2.0
RewriteCond "%{DOCUMENT_ROOT}/$1/2.0" -d
RewriteRule "^(.+)/current-version(/.*|$)" "$1/2.0$2"
# version:1.0
RewriteCond "%{DOCUMENT_ROOT}/$1/1.0" -d
RewriteRule "^(.+)/current-version(/.*|$)" "$1/1.0$2"
# Static redirection
Redirect "/desktop" "/products/windows"
Redirect "/windows" "/products/windows"
Redirect "/android" "/products/android"
Redirect "/ipad" "/products/iphone-and-ipad"
Redirect "/iphone" "/products/iphone-and-ipad"
Redirect "/iphone-and-ipad" "/products/iphone-and-ipad"
Redirect "/ios" "/products/iphone-and-ipad"
Redirect "/products/ipad" "/products/iphone-and-ipad"
Redirect "/products/iphone" "/products/iphone-and-ipad"
Redirect "/products/ios" "/products/iphone-and-ipad"
Redirect "/linux" "/products/linux"
Redirect "/debian" "/products/linux"
Redirect "/ubuntu" "/products/linux"
Redirect "/mac" "/products/mac"
Redirect "/macos" "/products/mac"
Redirect "/macosx" "/products/mac"
Redirect "/products/macos" "/products/mac"
Redirect "/products/macosx" "/products/mac"
Redirect "/web" "/products/web"
Redirect "/keymanweb" "/products/web"
Redirect "/products/keymanweb" "/products/web"
Redirect "/bookmarklet" "/products/bookmarklet"
#
# PHP and Markdown rewriting
#
# special case because of specific filenames : these don't redirect properly otherwise
# Rewrite nul -> _nul, index -> _index
RedirectMatch "^developer/language/reference/(nul|index)(\.php)?$" "developer/language/reference/_$1.php"
# Remove index or index.php and redirect
RedirectMatch "^((.+)/)?index(\.php)?$" "$1"
# Remove .php extension and redirect
RewriteCond "%{DOCUMENT_ROOT}/$1" -f
RewriteRule "^(.+)\.php$" "$1" [L]
# Redirect folder without / to include /
RewriteCond "%{DOCUMENT_ROOT}/$1" -d
RewriteCond "%{DOCUMENT_ROOT}/$1.php" !-f
RewriteCond "%{DOCUMENT_ROOT}/$1.md" !-f
RewriteRule "^(.+[^/])$" "$1" [L]
#
# PHP rewriting
#
# Rewrite file to file.md
RewriteCond "%{DOCUMENT_ROOT}/$1.md" -f
RewriteRule "^(.+)$" "/_includes/md/mdhost.php?file=$1.md"
RewriteCond "%{DOCUMENT_ROOT}/$1" -f
RewriteRule "^(.+\.md)$" "/_includes/md/mdhost.php?file=$1"
# Rewrite file to file.php
RewriteCond "%{DOCUMENT_ROOT}/$1.php" -f
RewriteCond "%{DOCUMENT_ROOT}/$1.md" !-f
RewriteRule "^(.+)$" "$1.php"
# Rewrite folder/ to folder/index.md
RewriteCond "%{DOCUMENT_ROOT}/$1/index.md" -f
RewriteRule "^(.+)$" "/_includes/md/mdhost.php?file=$1/index.md"
# Rewrite folder/ to folder/index.php
RewriteCond "%{DOCUMENT_ROOT}/$1/index.php" -f
RewriteCond %{DOCUMENT_ROOT}/$1/index.md !-f
RewriteRule "^(.+)$" "$1/index.php"