Skip to content

fix(RewriteRule): do not redirect for archive or English docs #1408

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 1 commit into from
Mar 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions www/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ RewriteRule ^.*docs/(\w\w(?:-\w\w)?)/latest$ {{site.baseurl}}/docs/$1/latest/ [R
RewriteRule ^.*docs/(\w\w(?:-\w\w)?)/latest/(.*)$ {{site.baseurl}}/docs/$1/{{site.latest_docs_version}}/$2 [L]

# Redirect http to https
# From Cordova PMC Member raphinesse
# From Cordova PMC Member raphinesse
# https://s.apache.org/An8s

# If we receive a forwarded http request from a proxy...
Expand All @@ -129,6 +129,19 @@ RewriteCond %{HTTPS} !=on
# Redirect to https version
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Redirect all docs translations to their English version
RewriteCond $1 !=en
RewriteRule ^.*docs/(\w\w(?:-\w\w)?)/(.*)$ {{site.baseurl}}/docs/en/$2 [R=302,L]
# Prevent redirecting away from archive URLs
RewriteCond %{REQUEST_URI} ^/archive/ [NC]
RewriteRule .* - [L]

# Prevent redirecting away from English docs
RewriteCond %{REQUEST_URI} ^/docs/en/ [NC]
RewriteRule .* - [L]

# Redirect all non-English documentation to the English version.
# If the English counterpart is missing, a 404 page will be displayed.
# Over time, the non-English documentation has fallen out of sync with the English version.
# For example, some pages may have been removed from the English documentation because they were no longer
# relevant or were merged into other pages, while the translated versions were not updated accordingly.
RewriteCond %{REQUEST_URI} ^/docs/(\w\w(?:-\w\w)?) [NC]
RewriteCond %1 !=en
RewriteRule ^docs/(\w\w(?:-\w\w)?)/(.*)$ /docs/en/$2 [R=302,L]