forked from Holzhaus/manual
-
Notifications
You must be signed in to change notification settings - Fork 0
/
htaccess
33 lines (27 loc) · 1.53 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
# This htaccess file is used to do verison and language redirects for the manual.
RewriteBase /manual
# Redirect people from /manual/ to /manual/latest/.
RewriteEngine on
RewriteRule ^$ latest/ [L,R=301]
# Since the redirects in this file vary based on the Accept-Language header, we
# set the Vary header so that reverse proxy caches (e.g. Cloudflare) know how to
# key the cache.
<IfModule mod_headers.c>
Header set Vary "Accept-Language"
</IfModule>
# Use english as default language
# Note: Even though we want to do this unconditionally, we can't use SetEnv
# here, because that runs *after* most early request processing directives are
# run. Using SetEnvIf is the recommended workaround.
# See https://httpd.apache.org/docs/2.4/mod/mod_env.html#setenv for details.
SetEnvIf _ ".*" MANUAL_LANGUAGE=en
# If the first language in the HTTP Accept-Language is in the list of supported
# languages, use it
# Important: Make sure to to list "lang-REGION" entries *before* the plain
# "lang" entry for that language to let them take precedence.
SetEnvIf Accept-Language "\b(ca|cs|de-DE|de|en-GB|es-ES|es-MX|es|fi|fr|gl|id|it|ja-JP|kn|nl|pl|pt-BR|pt|ro|ru-RU|ru|sl|sq|sr|tr|zh-CN|zh-TW)\b.*" MANUAL_LANGUAGE=$1
# Redirect to requested page in the language determined above, but only if no
# language is already present in the request URL
RewriteRule ^([^/]+)/?$ $1/%{ENV:MANUAL_LANGUAGE}/ [R=301,L]
RewriteRule ^([^/]+)/(chapters(?:/.*)?)$ $1/%{ENV:MANUAL_LANGUAGE}/$2 [R=301,L]
RewriteRule ^([^/]+)/(Mixxx-Manual\.pdf)$ $1/%{ENV:MANUAL_LANGUAGE}/$2 [R=301,L]