Skip to content

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

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

fix: Start to incorporate lang in URL paths 🌋#704
darcywong00 wants to merge 30 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 /file
  5. Rewrite rules

Additional small changes:

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

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

# Remove .php extension and redirect
#RewriteCond "$1.php" -f
#RewriteCond "$1" !-d
RewriteRule "^(.+).php$" "$1" [R,L]
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.

We need the same pattern for Markdown I think

Suggested change
RewriteRule "^(.+).php$" "$1" [R,L]
RewriteRule "^(.+)\.php$" "$1" [R,L]
RewriteRule "^(.+)\.md$" "$1" [R,L]

See for example:

http://keyman.com.localhost/en/about/team/bios/darcywong00.md should redirect to http://keyman.com.localhost/en/about/team/bios/darcywong00

# ------------------------------------------------------------------

# Remove index.md or index.php and redirect (and stop processing)
#RewriteCond "$1" -d
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
#RewriteCond "$1" -d

Comment on lines +50 to +51
#RewriteCond "$1.php" -f
#RewriteCond "$1" !-d
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
#RewriteCond "$1.php" -f
#RewriteCond "$1" !-d


# Remove index.md or index.php and redirect (and stop processing)
#RewriteCond "$1" -d
RewriteRule "^((.+)/)?index(.md|.php)?$" "$1" [R,L]
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
RewriteRule "^((.+)/)?index(.md|.php)?$" "$1" [R,L]
RewriteRule "^((.+)/)?index(\.md|\.php)?$" "$1" [R,L]

# ------------------------------------------------------------------

# Redirect /archive/downloads.php"
RewriteRule "^archive/downloads(.php)?$" "/downloads/archive/" [NC,R=301,QSA]
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
RewriteRule "^archive/downloads(.php)?$" "/downloads/archive/" [NC,R=301,QSA]
RewriteRule "^archive/downloads(.php)?$" "/downloads/archive/" [NC,R=301,END,QSA]

? I am not sure if END is required for redirects?

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

</div>
<!--<div class="download-cta-small Bookmarklet" id="cta-Bookmarklet">
<a href="../../../bookmarklet/">
<a href="../../../../bookmarklet/">
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
<a href="../../../../bookmarklet/">
<a href="../../../bookmarklet/">

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

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

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

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.

3 participants