Repository navigation
Send old ?locale=ru|zh page addresses to the page in that language #409
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| # `?locale=ru` and `?locale=zh` on a page, sent to the page in that language. | ||
| # | ||
| # The Rails site named the language in a parameter, and the search engines | ||
| # still hold those addresses: on 2026-10-08 Google had 110 of openipc.org's | ||
| # 671 URLs with impressions carrying a query string, and | ||
| # /cameras/vendors/sigmastar/socs/ssc30kq?locale=ru alone earned 35 clicks in | ||
| # four weeks. The bundle ignores the parameter, so every one of those readers | ||
| # got the English page, and its canonical told the engine the English page | ||
| # was the one to keep. The home page's script has always turned `/?locale=ru` | ||
| # into `/ru` (frontend/apps/site/src/pages/index.astro); this does the same | ||
| # for every page, before a byte of the wrong language is sent. | ||
| # | ||
| # Only a read, only a language the site publishes, only an address without a | ||
| # language of its own, and only a page: a name with a dot is a file. Anything | ||
| # else on the query string goes along. Behind openipc.ru the Location is | ||
| # rewritten by the mirror like every other redirect, so a reader there stays | ||
| # there. | ||
| # | ||
| # Built from $request_uri and $args, never $uri: $uri is decoded, and a | ||
| # decoded %0d%0a in a Location header is a header of the requester's choosing. | ||
| # | ||
| # The Open Wall's own `?locale=` is conf.d/openipc-wall-shell.conf's, in | ||
| # locations of its own; this is applied in the seam's `location /` only. | ||
|
|
||
| # The path to localise: "/" for the home page, the path for any other page, | ||
| # and empty for an address that already names its language, is a file, or is | ||
| # percent-encoded. The route map classifies the decoded $uri, and /%72u/donate | ||
| # is /ru/donate to it; a raw path like that left alone is answered as it was. | ||
| # Regexes are tried in order, so the home page is decided first. | ||
| map $request_uri $openipc_lp_path { | ||
| default ""; | ||
| "~^/(?:\?.*)?$" "/"; | ||
| "~^/(?:ru|zh)(?:[/?]|$)" ""; | ||
| "~^[^?]*\." ""; | ||
| "~^[^?]*%" ""; | ||
| "~^(?<openipc_lp_p>/[^?]*)" $openipc_lp_p; | ||
| } | ||
|
|
||
| # The query string without `locale`, with its `?`, or nothing at all. | ||
| map $args $openipc_lp_args { | ||
| default "?$args"; | ||
| "" ""; | ||
| "~^locale=[^&]*$" ""; | ||
| "~^locale=[^&]*&(?<openipc_lp_rest>.+)$" "?$openipc_lp_rest"; | ||
| "~^(?<openipc_lp_pre>.*?)&locale=[^&]*(?<openipc_lp_post>&.*)?$" "?$openipc_lp_pre$openipc_lp_post"; | ||
|
qodo-free-for-open-source-projects[bot] marked this conversation as resolved.
|
||
| } | ||
|
|
||
| # Only where the route map (conf.d/openipc-redirects.conf) has nothing of its | ||
| # own to say: a page, or an address nothing claims. An address it redirects or | ||
| # retires is answered by it first, and a `?locale=` the redirect carries along | ||
| # is honoured on the next request -- /about?locale=zh goes to | ||
| # /community?locale=zh and from there to /zh/community. | ||
| map $openipc_route_action $openipc_lp_routable { | ||
| default ""; | ||
| page 1; | ||
| catchall 1; | ||
| } | ||
|
|
||
| # One `locale` only. $arg_locale is the first of several, and the others would | ||
| # ride along on the localised address with nothing left to remove them. | ||
| map $args $openipc_lp_once { | ||
| default 1; | ||
| "~(?:^|&)locale=[^&]*&(?:.*&)?locale=" ""; | ||
| } | ||
|
|
||
| map "$request_method:$openipc_lp_routable$openipc_lp_once:$arg_locale:$openipc_lp_path" $openipc_locale_param_target { | ||
| default ""; | ||
| "~^(?:GET|HEAD):11:(?<openipc_lp_l>ru|zh):/$" "/$openipc_lp_l$openipc_lp_args"; | ||
| "~^(?:GET|HEAD):11:(?<openipc_lp_l>ru|zh):(?<openipc_lp_q>/.+)$" "/$openipc_lp_l$openipc_lp_q$openipc_lp_args"; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.