blob: 68a245dc8f7e278220a7913ebe4f2cdec81d37c5 (
plain)
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
|
##
## AUTO NEGOTIATED LOCALE
##
LanguagePriority en
ForceLanguagePriority Prefer Fallback
DirectoryIndex index
DirectorySlash Off
Options +MultiViews
##
## REWRITES
##
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
##
## remove trailing slashes (except for paths where we added the slash)
##
# /en/ => /en
RewriteCond %{QUERY_STRING} !end
RewriteRule ^([a-z]{2})/$ /$1 [R=307,L]
# /en/aaa/ => /en/aaa
RewriteCond %{QUERY_STRING} !end
RewriteCond %{REQUEST_URI} ^/([a-z]{2})/
RewriteCond %{REQUEST_URI} !\.html$
RewriteRule ^(.+)/$ /$1 [R=307,L]
# /foo/bar.en.html/ => /foo/bar
RewriteCond %{QUERY_STRING} !end
RewriteCond %{REQUEST_URI} \.html/$
RewriteRule ^(.+)\.[a-z]{2}\.html/$ $1 [R=307,L]
# /foo/bar/ => /foo/blah
RewriteCond %{QUERY_STRING} !end
RewriteRule ^(.+)/$ $1 [R=307,L]
##
## rewrite all paths with a local prefix to use
## the appropriate index.{local}.html file or
## filename.{local}.html file.
##
# /en => /index.en.html
RewriteCond %{QUERY_STRING} !end
RewriteCond %{DOCUMENT_ROOT}/index.$1.html -f
RewriteCond %{REQUEST_URI} ^/([a-z]{2})$
RewriteRule ^(.*) /index.%1.html?end [L]
# /en/aaa => /aaa/index.en.html
RewriteCond %{QUERY_STRING} !end
RewriteCond %{DOCUMENT_ROOT}/$2/index.$1.html -f
RewriteRule ^([a-z]{2})/(.*) /$2/index.$1.html?end [L]
# /de/foo/bar => /foo/bar.de.html
RewriteCond %{QUERY_STRING} !end
RewriteCond %{DOCUMENT_ROOT}/$2.$1.html -f
RewriteRule ^([a-z]{2})/(.*) /$2.$1.html?end [L]
##
## internally simulate a trailing slashes for directories in order
## to trigger DirectoryIndex and autonegotiated locale.
##
# /foo/bar => /foo/bar/
RewriteCond %{QUERY_STRING} !end
RewriteCond %{DOCUMENT_ROOT}/$1 -d
RewriteRule ^(.*[^/])$ /$1/?end [PT]
##
## redirect assets that are locale prefixed
## (in order to allow relative paths)
##
# e.g. /de/foo/assets/style.css => /foo/assets/style.css
RewriteCond %{QUERY_STRING} !end
RewriteCond %{DOCUMENT_ROOT}/$2 -f
RewriteRule ^([a-z]{2})/(.*) /$2 [R=307,L]
|