Skip to content

fix: Start to incorporate lang in URL paths 🌋#704

Open
darcywong00 wants to merge 39 commits intoepic/i18n-url-schemefrom
fix/lang/htaccess
Open

fix: Start to incorporate lang in URL paths 🌋#704
darcywong00 wants to merge 39 commits intoepic/i18n-url-schemefrom
fix/lang/htaccess

Conversation

@darcywong00
Copy link
Copy Markdown
Contributor

@darcywong00 darcywong00 commented Mar 31, 2026

Follows #696

This overhauls .htaccess files to handle a langtag in the URL path (rewrite to corresponding _content/ path).
Flow of .htaccess:

  1. Redirections before rewriting
  2. Remove file extensions from links
  3. Known path redirections
  4. i18n redirect --> /file to <lang>/file
  5. Rewrite rules

Additional small changes:

  • Moved ‎_content/archive/.htaccess rule to the root .htaccess
  • cleanup downloads path
  • cleanup some _test page links

CI link checker will may still fail

Test-bot: skip

@darcywong00 darcywong00 added this to the A19S26 milestone Mar 31, 2026
@darcywong00 darcywong00 requested a review from mcdurdin March 31, 2026 03:39
@keymanapp-test-bot
Copy link
Copy Markdown

User Test Results

Test specification and instructions

User tests are not required

Comment thread .htaccess Outdated
@darcywong00 darcywong00 marked this pull request as draft April 2, 2026 08:49
@darcywong00 darcywong00 marked this pull request as ready for review April 6, 2026 01:21
Comment thread _content/android/app/index.php Outdated
@@ -0,0 +1,4 @@
<?php
// Redirect to Android homepage
header('Location: https://help.keyman.com/products/android/');
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converted from /_content/android/app/.htaccess - also done for iphone-and-ipad/app

Root .htaccess rules weren't matching

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, will convert this too top level .htaccess rule(s)

Comment thread .htaccess Outdated
Comment thread .htaccess Outdated
Comment thread .htaccess Outdated
Comment thread .htaccess Outdated
Comment thread .htaccess Outdated
Comment thread _content/keyboards/h/tamil/index.php Outdated
</div>
<div class="download-cta-small iPad" id="cta-iPad">
<a href="../../../ipad/">
<a href="../../../../ipad/">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto?

Comment thread _content/keyboards/h/urdu/index.php Outdated
Comment thread _content/windows/index.php Outdated
</p>
<p>
<span class="red">A.</span> Yes, you can find the links to download Keyman Desktop 7.1 and other previous releases <a href="../archive/downloads.php">here</a>.
<span class="red">A.</span> Yes, you can find the links to download Keyman Desktop 7.1 and other previous releases <a href="/archive/downloads">here</a>.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<span class="red">A.</span> Yes, you can find the links to download Keyman Desktop 7.1 and other previous releases <a href="/archive/downloads">here</a>.
<span class="red">A.</span> Yes, you can find the links to download Keyman Desktop 7.1 and other previous releases <a href="../archive/downloads">here</a>.

Why make the path absolute again?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This depends on the root level redirect

keyman.com/.htaccess

Lines 64 to 65 in 11c3a70

# Redirect /archive/downloads.php"
RewriteRule "^archive/downloads(.php)?$" "/downloads/archive/" [NC,R=301,QSA]

When I make it relative path, I get a 404

Image

Since this is our own link, maybe I should just fix it to ../downloads/archive

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely we should fix the link on our site, no point in additional complexity and redirects.

But this highlights an upcoming issue with redirects which I think we kinda decided punt until later: what do we do with things like keyman.com/khmer --> /keyboards/khmer_angkor? Do we also support keyman.com/en/khmer --> /en/keyboards/khmer_angkor? Do we do this for all redirects or a subset or none?

I am unsure.

Comment on lines -16 to -18
// Fallback to 'en'
// TODO-I18N-URL-SCHEME: integrate with Locale.php
$fields->lang = isset($_REQUEST['lang']) ? $_REQUEST['lang'] : 'en';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this? We'll need something like this throughout

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I got mixed up thinking the new .htaccess rules would handle the language tag.

So we want to keep $fields->lang for Foot, Menu?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we'll want to keep those fields but they'll need to be extracted from the URL. I think we'll be able to parse the URL as it should be the first path component, rather than using URL rewriting to append a lang parameter?

Comment thread _test/index.md Outdated
## Links to Other Test Pages

[/go links](./go)
[/go links](/_test/go)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI link checker test was failing
https://github.com/keymanapp/keyman.com/actions/runs/24058950224/job/70171010949#step:7:18

I don't quite understand it, but the CI link checker would treat these links as:

Getting links from: http://localhost:8053/_test
├─BROKEN─ http://localhost:8053/go (HTTP_403)
├─BROKEN─ http://localhost:8053/language-landing (HTTP_404)
├─BROKEN─ http://localhost:8053/legacy (HTTP_404)
├─BROKEN─ http://localhost:8053/well-known (HTTP_404)
Error: Process completed with exit code 1.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that the rule which appends a / in a redirect for index.md is missing or out of order; we'll need that.

  • /_test should redirect to /_test/ because it is a folder.

alongside the rules that strip .php and .md suffix and deal with index filename:

  • /_test/index.php -> /_test/index
  • /_test/index.md -> /_test/index
  • /_test/index -> /_test/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k, still troubleshooting this one.
Will get back to this after Songkran break!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aha, {DOCUMENT_ROOT} needed to be %{DOCUMENT_ROOT}

fixed in 88769e9 along with

  • cleaning up links in _test
  • cleaning up unncessary \/ to / in .htaccess

Comment thread _includes/2020/templates/Foot.php Outdated
<a href="/<?=$fields->lang?>/about/"><img id="sil-logo" src="<?php echo ImageRandomizer::randomizer(); ?>" width="50%" alt='SIL' /></a>
<p>Created by <a href="/<?=$fields->lang?>/about/">SIL Global</a></p>
<a href="/about/"><img id="sil-logo" src="<?php echo ImageRandomizer::randomizer(); ?>" width="50%" alt='SIL' /></a>
<p>Created by <a href="/about/">SIL Global</a></p>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, why doesn't about SIL Global go to https://global.sil.org/about/ ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, probably should!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handled in #711

@keyman-server keyman-server modified the milestones: A19S26, A19S27 Apr 14, 2026
</p>
<p>
<span class="red">A.</span> Yes, you can find the links to download Keyman Desktop 7.1 and other previous releases <a href="../archive/downloads.php">here</a>.
<span class="red">A.</span> Yes, you can find the links to download Keyman Desktop 7.1 and other previous releases <a href="../downloads/archive">here</a>.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link is cleaned up

Comment thread _includes/2020/templates/Menu.php Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

4 participants