This question pertains to publishing the Ubuntu Serverguide on help.ubuntu.com. For the 20.04 LTS cycle, there will (O.K. might) be significant changes to the source code workflow for the Ubuntu Serverguide. Currently, translations are not being considered for this migration. Our best feedback has been that server admin types prefer English, even if it is not their first language. Before the decision becomes non reversible, we want to test it by doing the next point release of the 18.04 Ubuntu Serverguide in U.S. English only. Everything is ready, except for one issue:
We know for certain that many links, bookmarks, etc. exist with the language extension. Example:
https://help.ubuntu.com/lts/serverguide/networking.html.en-CA
And we want to have that scenario return this page instead:
https://help.ubuntu.com/lts/serverguide/networking.html
because the language specific versions will no longer exist, but returning a 404 Not Found error is undesirable.
The current version of an .htaccess file, with commented out previous attempts, is:
# unable to make below method work.
#RedirectMatch permanent ^(*\.html)\.*$ $1
#
# enable rewriting
RewriteEngine on
#RewriteRule ^(*\.html)\.*$ $1 [R=301, L]
#RewriteRule ^(*\.html)\.*$ $1
RewriteRule ^(*\.html)\.*$ $1 [PT]
#RewriteRule ^(*.html).*$ $1
Resulting in:
500 Internal Server Error
to the client, and this in the test server logs:
[Thu Jun 20 11:57:07.647838 2019] [core:alert] [pid 16079] [client 192.168.111.101:62992] /home/doug/public_html/linux/ubuntu-docs/help.ubuntu.com/dev/lts/serverguide/.htaccess: RewriteRule: cannot compile regular expression '^(*\\.html)\\.*$', referer: http://my-test-website/~doug/linux/ubuntu-docs/help.ubuntu.com/dev/index.html
[Thu Jun 20 14:19:27.360334 2019] [core:alert] [pid 16079] [client 192.168.111.101:63908] /home/doug/public_html/linux/ubuntu-docs/help.ubuntu.com/dev/lts/serverguide/.htaccess: RewriteRule: cannot compile regular expression '^(*\\.html)\\.*$', referer: http://my-test-website/~doug/linux/ubuntu-docs/help.ubuntu.com/dev/index.html
Notice that current attempts are with a wildcard for the language extension. If that is not possible, then the language list is:
ace ar ast be bg bn bs ca cs da de el en en_AU en_CA en_GB eo es et eu fa fi fr gl gu he hr hu id is it ja km ko ku lo lt lv mk ms nb nl oc pl ps pt_BR pt ro ru sk sl sq sr sv th tl tr ug uk ur vi zh_CN zh_TW
Can someone help with this?
This rewrites
/foobar.html.anything
into/foobar.html
, and seems to do what you want.If it is intended to be permanent, you should probably send a 301: