-
-
Notifications
You must be signed in to change notification settings - Fork 7
fix: Start to incorporate lang in URL paths 🌋 #704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 30 commits
6f8fdae
863f677
d98b236
f4d6d99
91d69b5
cd9fd45
8b3f67e
a0f3d86
3804817
839fb40
1583b34
7ca0e01
57ad35d
37273da
95bbf29
bf9897e
7634f84
93bad37
53ba79a
35f00a4
3822271
a92ac18
7965b0a
5c1970b
be580bd
224561f
948550f
b37b468
5dd6beb
11c3a70
2440249
7a434a0
2211c08
c44bd72
5531862
490a0f5
3b78d44
88769e9
7566f6b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,14 +24,49 @@ RewriteBase / | |
| AddType application/json apple-app-site-association | ||
|
|
||
| # Deny crowdin.yml | ||
| RewriteRule ^crowdin.yml$ = [F,L] | ||
| RewriteRule "^crowdin.yml$" = [F,L] | ||
|
|
||
| # Custom error messages (need to pass the original request) | ||
| ErrorDocument 404 /_includes/errors/404 | ||
| ErrorDocument 404 /_includes/errors/404.php | ||
|
|
||
| RewriteRule "^_includes/errors/404(.php)?$" "/_includes/errors/404.php" [END] | ||
|
|
||
| # apple-app-site-association | ||
| RewriteRule "^.well-known/apple-app-site-association$" "/.well-known/apple-app-site-association.json" [L] | ||
|
|
||
| # ################################################################## | ||
| # Redirections - before rewriting | ||
| # ################################################################## | ||
|
|
||
| # ------------------------------------------------------------------ | ||
| # PHP and Markdown redirections | ||
| # ------------------------------------------------------------------ | ||
|
|
||
| # Remove index.md or index.php and redirect (and stop processing) | ||
| #RewriteCond "$1" -d | ||
| RewriteRule "^((.+)/)?index(.md|.php)?$" "$1" [R,L] | ||
|
darcywong00 marked this conversation as resolved.
Outdated
|
||
|
|
||
| # Remove .php extension and redirect | ||
| #RewriteCond "$1.php" -f | ||
| #RewriteCond "$1" !-d | ||
|
darcywong00 marked this conversation as resolved.
Outdated
|
||
| RewriteRule "^(.+).php$" "$1" [R,L] | ||
|
darcywong00 marked this conversation as resolved.
Outdated
|
||
|
|
||
| # Redirect folder without / to include / | ||
| RewriteCond "{DOCUMENT_ROOT}/$1" -d | ||
| RewriteCond "{DOCUMENT_ROOT}/$1.php" !-f | ||
| RewriteCond "{DOCUMENT_ROOT}/$1.md" !-f | ||
| RewriteRule "^(.+[^/])$" "$1/" [R,END] | ||
|
|
||
| # ------------------------------------------------------------------ | ||
| # Known path redirections | ||
| # ------------------------------------------------------------------ | ||
|
|
||
| # Redirect /archive/downloads.php" | ||
| RewriteRule "^archive/downloads(.php)?$" "/downloads/archive/" [NC,R=301,QSA] | ||
|
darcywong00 marked this conversation as resolved.
Outdated
|
||
|
|
||
| # ios and iphone and ipad to iphone-and-ipad | ||
| RewriteRule "^(ios|iphone|ipad)(\/.*)?$" "/iphone-and-ipad$2" [NC,R=301,END,QSA] | ||
|
|
||
| # macosx and macos to mac (ignore case) | ||
| RewriteRule "^(macosx|macos)\b(.*)$" "/mac$2" [NC,R=301,END,QSA] | ||
|
|
||
|
|
@@ -50,14 +85,7 @@ RedirectMatch 301 "^(?i)/privacy(\/.*)?" "https://software.sil.org/language-soft | |
| # desktop to windows | ||
| RewriteRule "^desktop(/.*)?" "/windows$1" [NC,R=301,END,QSA] | ||
|
|
||
| # releases-tier/download | ||
| # note: the tier is currently ignored | ||
| RewriteRule "^downloads/releases/(alpha|beta|stable)/(.+)$" "/downloads/releases/_version_downloads.php?tier=$1&version=$2" [END] | ||
|
|
||
| # releases-download | ||
| RewriteRule "^downloads/releases/(.+)$" "/downloads/releases/_version_downloads.php?version=$1" [END] | ||
|
|
||
| # index | ||
| # releases-download index | ||
| RewriteRule "^downloads/releases(\/)?$" "/downloads" [R,END] | ||
|
|
||
| # CLDR -> LDML | ||
|
|
@@ -86,57 +114,12 @@ RewriteRule "^keyboards/(.*)/share(/?)$" "/keyboards/share/$1" [R=301] | |
| # /keyboard/{content} to /keyboards/... | ||
| RewriteRule "^keyboard(/.*)$" "/keyboards$1" [R,END] | ||
|
|
||
| # | ||
| # Install | Download | Share | bare | .json --> | ||
| # | ||
|
|
||
| # /keyboards/install/[id] to /keyboards/install.php | ||
| RewriteRule "^keyboards/install/([^/]+)$" "/keyboards/install.php?id=$1" [END,QSA] | ||
|
|
||
| # /keyboards/download/[id] to /keyboards/keyboard.php | ||
| # This formerly redirected to a download, but we no longer need it; keep it for | ||
| # legacy links | ||
| RewriteRule "^keyboards/download/([^/]+)$" "/keyboards/keyboard.php?id=$1" [END,QSA] | ||
|
|
||
| # /keyboards/share/[id] to /keyboards/share.php | ||
| # if the keyboard exists in the repo, then share.php will redirect to /keyboards/<id> | ||
| RewriteRule "^keyboards/share/([^/]+)$" "/keyboards/share.php?id=$1" [END,QSA] | ||
|
|
||
| # /keyboards/{id}.json to /keyboards/keyboard.json.php | ||
| RewriteRule "^keyboards/(?!keyboard.json)(.*)\.json$" "/keyboards/keyboard.json.php?id=$1" [END] | ||
|
|
||
| # /keyboards/{id} to /keyboards/keyboard.php | ||
| RewriteRule "^keyboards/(?!index\.php|install|keyboard|session|share)([^/]+)$" "/keyboards/keyboard.php?id=$1" [END,QSA] | ||
|
|
||
|
|
||
| # | ||
| # Search | ||
| # | ||
|
|
||
| # /keyboards?q=... to /keyboards/index.php | ||
| # RewriteRule "^keyboards$" "/keyboards/index.php" [L] | ||
|
|
||
| # /keyboards/languages to /keyboards/index.php | ||
| RewriteRule "^keyboards/languages/(.*)" "/keyboards/index.php?q=l:id:$1" [END,QSA] | ||
|
|
||
| # /keyboards/download to /keyboards/download.php | ||
| RewriteRule "^keyboards/download(.php)?" "/keyboards/download.php" [END,QSA] | ||
|
|
||
| # /keyboards/legacy to /keyboards/keyboard.php | ||
| RewriteRule "^keyboards/legacy/(.*)" "/keyboards/keyboard.php?legacy=$1" [END] | ||
|
|
||
| # /keyboards/countries to /keyboards/index.php | ||
| RewriteRule "^keyboards/countries/(.*)" "/keyboards/index.php?q=c:id:$1" [END] | ||
|
|
||
| # Synonym paths | ||
|
|
||
| # 10.0 to 15.0 | ||
| # /1X.0 to /1X landing page | ||
| RedirectMatch "^/1([0-5])(\.0)\/?" "/1$1/" | ||
|
|
||
| # ios | ||
| RedirectMatch "^/(?!iphone-and-ipad)(ios|iphone|ipad)(\/.*)?" "/iphone-and-ipad$2" | ||
|
|
||
| # Connect With Art landing page | ||
| RedirectMatch "/connectwithart(\/|$)" "https://sites.google.com/sil.org/connectwithart/home" | ||
|
|
||
|
|
@@ -180,52 +163,147 @@ RedirectMatch "^/(french|german|italian|spanish|swedish)(/?)$" "/keyboards | |
| # dedicated-keyboard-landing pages | ||
| RedirectMatch 301 "^/(amharic|burmese|cameroon|ethiopic|eurolatin|greek|ipa|sinhala|tamil|tibetan|tigrigna|urdu)(/.*)?$" "/keyboards/h/$1$2" | ||
|
|
||
| # ------------------------------------------------------------------ | ||
| # i18n redirect --> /file to <lang>/file | ||
| # ------------------------------------------------------------------ | ||
|
|
||
| # | ||
| # PHP and Markdown rewriting | ||
| # if $1 is a folder or file in /_content, then redirect to currentlang (en?) | ||
| # e.g. would redirect windows/download --> en/windows/download/ | ||
| RewriteCond "%{DOCUMENT_ROOT}/_content/$1.php" -f [OR] | ||
| RewriteCond "%{DOCUMENT_ROOT}/_content/$1.md" -f [OR] | ||
| RewriteCond "%{DOCUMENT_ROOT}/_content/$1" -d | ||
| RewriteRule "^(.*)$" "en/$1" [R,L] | ||
|
|
||
| # | ||
| # Paths involving queries (don't match on file/directory) | ||
| RewriteRule "^(downloads\/releases|keyboards)/(.+)$" "en/$1/$2" [R,L] | ||
|
|
||
| # Remove index or index.php and redirect (and stop processing) | ||
| RewriteCond "$1" -d | ||
| RewriteRule "^((.+)/)?index(\.php)?$" "$1" [R,L] | ||
| # ################################################################## | ||
| # Rewriting | ||
| # ################################################################## | ||
|
|
||
| # Remove .php extension and redirect | ||
| RewriteCond "$1.php" -f | ||
| RewriteCond "$1" !-d | ||
| RewriteRule "^(.+)\.php$" "$1" [R,L] | ||
| # ------------------------------------------------------------------ | ||
| # top-level content without i18n - _control/, go/, _test/ | ||
| # ------------------------------------------------------------------ | ||
|
|
||
| # Redirect folder without / to include / | ||
| RewriteCond "{DOCUMENT_ROOT}/$1" -d | ||
| RewriteCond "{DOCUMENT_ROOT}/$1.php" !-f | ||
| RewriteCond "{DOCUMENT_ROOT}/$1.md" !-f | ||
| RewriteRule "^(.+[^/])$" "$1/" [R,END] | ||
| # No i18n - won't go to _content | ||
|
|
||
| RewriteCond "%{DOCUMENT_ROOT}/$1/$2.php" -f | ||
| RewriteRule "^(_control|go|_test)/(.+)$" "/$1/$2.php" [END] | ||
|
|
||
| RewriteCond "%{DOCUMENT_ROOT}/$1/$2.md" -f | ||
| RewriteRule "^(_control|go|_test)/(.+)$" "/_includes/includes/md/mdhost.php?file=$1/$2.md" [END] | ||
|
|
||
| RewriteCond "%{DOCUMENT_ROOT}/$1/index.md" -f | ||
| RewriteRule "^(_control|go|_test)/?$" "/_includes/includes/md/mdhost.php?file=$1/index.md" [END] | ||
|
|
||
| # | ||
| # keyboards Install | Download | Share | bare | .json --> | ||
| # | ||
|
|
||
| # /keyboards/install/[id] to /keyboards/install.php | ||
| RewriteRule "^(en)/keyboards/install/([^/]+)$" "/_content/keyboards/install.php?id=$2&lang=$1" [END,QSA] | ||
|
|
||
| # /keyboards/download/[id] to /keyboards/keyboard.php | ||
| # This formerly redirected to a download, but we no longer need it; keep it for | ||
| # legacy links | ||
| RewriteRule "^(en)/keyboards/download/([^/]+)$" "/_content/keyboards/keyboard.php?id=$2&lang=$1" [END,QSA] | ||
|
|
||
| # /keyboards/share/[id] to /keyboards/share.php | ||
| # if the keyboard exists in the repo, then share.php will redirect to /keyboards/<id> | ||
| RewriteRule "^(en)/keyboards/share/([^/]+)$" "/_content/keyboards/share.php?id=$2&lang=$1" [END,QSA] | ||
|
|
||
| # /keyboards/{id}.json to /keyboards/keyboard.json.php | ||
| RewriteRule "^(en)/keyboards/(?!keyboard.json)(.*)\.json$" "/_content/keyboards/keyboard.json.php?id=$2&lang=$1" [END] | ||
|
|
||
| # /keyboards/{id} to /keyboards/keyboard.php | ||
| RewriteRule "^(en)/keyboards/(?!index\.php|install|keyboard|session|share)([^/]+)$" "/_content/keyboards/keyboard.php?id=$2&lang=$1" [END,QSA] | ||
|
|
||
| # | ||
| # keyboards search | ||
| # | ||
|
|
||
| # /keyboards/languages to /keyboards/index.php | ||
| RewriteRule "^(en)/keyboards/languages/(.*)" "/_content/keyboards/index.php?q=l:id:$2&lang=$1" [END,QSA] | ||
|
|
||
| # /keyboards/download to /keyboards/download.php | ||
| RewriteRule "^(en)/keyboards/download(.php)?" "/_content/keyboards/download.php?lang=$1" [END,QSA] | ||
|
|
||
| # /keyboards/legacy to /keyboards/keyboard.php | ||
| RewriteRule "^(en)/keyboards/legacy/(.*)" "/_content/keyboards/keyboard.php?legacy=$2&lang=$1" [END] | ||
|
|
||
| # /keyboards/countries to /keyboards/index.php | ||
| RewriteRule "^(en)/keyboards/countries/(.*)" "/_content/keyboards/index.php?q=c:id:$2&lang=$1" [END] | ||
|
|
||
|
|
||
| # | ||
| # contact/exception | ||
| # | ||
|
|
||
| # /contact/exception to /contact/exception.php | ||
| RewriteRule "^(en)/contact/exception(.php)?" "/_content/contact/exception.php?lang=$1" [END,QSA] | ||
|
|
||
| RewriteRule "^(en)/contact/exception?id=(.+)$" "/_content/contact/exception?id=$2&lang=$1" [END] | ||
|
|
||
| # | ||
| # ios | ||
| # | ||
| RewriteRule "^(en)/(iphone|ipad)(\/.*)?" "/_content/iphone-and-ipad/$3?lang=$1" [END,QSA] | ||
|
|
||
| # | ||
| # downloads/releases | ||
| # | ||
|
|
||
| # releases-tier/download | ||
| # note: the tier is currently ignored | ||
| RewriteRule "^(en)/downloads/releases/(alpha|beta|stable)/(.+)$" "/_content/downloads/releases/_version_downloads.php?tier=$2&version=$3&lang=$1" [END] | ||
|
|
||
| # releases-download | ||
| RewriteRule "^(en)/downloads/releases/(.+)$" "/_content/downloads/releases/_version_downloads.php?version=$2&lang=$1" [END] | ||
|
|
||
| # | ||
| # PHP rewriting | ||
| # Assets don't use lang param | ||
| # | ||
| RewriteCond "%{DOCUMENT_ROOT}/cdn/$1$2" -f | ||
| RewriteRule "^cdn/(.+\.)(gif|js|png|svg)$" "/cdn/$1$2" [END] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be with the _control/go/_test rules |
||
|
|
||
| RewriteRule "^(en)/(.+\.)(gif|js|png|svg)$" "/_content/$2$3" [END] | ||
|
darcywong00 marked this conversation as resolved.
Outdated
|
||
|
|
||
| # TODO: do we want en/lao --> en/keyboards/basic_kbdlao? as well as /lao --> ... | ||
|
|
||
| # | ||
| # PHP and Markdown rewriting | ||
| # | ||
|
|
||
| # TODO: mdhost currently in a different path than help.keyman | ||
|
|
||
| # TODO: en --> should be a bcp-47 type 'lang' match (e.g. ab[-x][-y]) ignore case, keep it a fairly loose expression [a-z][a-z][a-z]?(-...)? | ||
|
|
||
| ############################################## | ||
|
|
||
| # Rewrite file to file.md | ||
| RewriteCond "%{DOCUMENT_ROOT}/$1.md" -f | ||
| RewriteRule "^(.+)$" "/_includes/includes/md/mdhost.php?file=$1.md" [END] | ||
| RewriteCond "%{DOCUMENT_ROOT}/_content/$2.md" -f | ||
| RewriteRule "^(en)/(.+)$" "/_includes/includes/md/mdhost.php?file=_content/$2.md&lang=$1" [END] | ||
|
|
||
| # Rewrite file to file.php | ||
| RewriteCond "%{DOCUMENT_ROOT}/$1.php" -f | ||
| RewriteCond "%{DOCUMENT_ROOT}/$1.md" !-f | ||
| RewriteRule "^(.+)$" "$1.php" [END] | ||
| RewriteCond "%{DOCUMENT_ROOT}/_content/$2.php" -f | ||
| RewriteCond "%{DOCUMENT_ROOT}/_content/$2.md" !-f | ||
| RewriteRule "^(en)/(.+)$" "/_content/$2.php?lang=$1" [END] | ||
|
|
||
| # Rewrite folder/ to folder/index.md | ||
| RewriteCond "%{DOCUMENT_ROOT}/$1/index.md" -f | ||
| RewriteRule "^(.+)/$" "/_includes/includes/md/mdhost.php?file=$1/index.md" [END] | ||
| RewriteCond "%{DOCUMENT_ROOT}/_content/$2/index.md" -f | ||
| RewriteRule "^(en)/(.+)/$" "/_includes/includes/md/mdhost.php?file=_content/$2/index.md&lang=$1" [END] | ||
|
|
||
| # Rewrite folder/ to folder/index.php | ||
| RewriteCond "%{DOCUMENT_ROOT}/$1/index.php" -f | ||
| RewriteCond "%{DOCUMENT_ROOT}/$1/index.md" !-f | ||
| RewriteRule "^(.+)/$" "$1/index.php" [END] | ||
| RewriteCond "%{DOCUMENT_ROOT}/_content/$2/index.php" -f | ||
| RewriteCond "%{DOCUMENT_ROOT}/_content/$2/index.md" !-f | ||
| RewriteRule "^(en)/(.+)/$" "/_content/$2/index.php?lang=$1" [END] | ||
|
|
||
| # Root page | ||
| RewriteRule "^(en)/$" "/_content/index.php?lang=$1" [END] | ||
|
|
||
| # Finally, append the terminating slash for folders, given it is no longer | ||
| # done automatically because we put DirectorySlash off | ||
| RewriteCond %{REQUEST_FILENAME} -d | ||
| RewriteRule "^(.*)([^/])$" "$1$2/" [R] | ||
|
|
||
|
|
||
| RewriteCond "%{DOCUMENT_ROOT}/_content/$2$3" -d | ||
| RewriteRule "^(en)(.*)([^/])?$" "$1$2$3/" [R,QSA] | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| <?php | ||
| // Redirect to Android homepage | ||
| header('Location: https://help.keyman.com/products/android/'); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Converted from Root .htaccess rules weren't matching
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little uncomfortable with this change -- it might be better to add the rule at the top level .htaccess?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, will convert this too top level .htaccess rule(s) |
||
| ?> | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,5 +29,5 @@ | |
|
|
||
|
|
||
| <?php | ||
| require_once('./_downloads.php'); | ||
| require_once('_downloads.php'); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this change? The
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ic, will revert |
||
| ?> | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| <?php | ||
| // Redirect to help.keyman.com | ||
| header('Location: https://help.keyman.com/products/iphone-and-ipad/'); | ||
| ?> |
Uh oh!
There was an error while loading. Please reload this page.