On Tue, Jul 30, 2019 at 1:47 PM Paul Wise wrote: > Passing cookies for this could work easily, but discussing it a while > ago we decided there could be GDPR issues. I seem to remember I worked > out that via some Apache rewrite rules it would be possible to use the > names of top-level directories to influence content negotiation, but I > neglected to take notes about how.
It looks like we just need to set the prefer-language Apache variable and it looks like there is a way to do that based on the domain, subdirectory, cookies or almost anything else we could think of. https://httpd.apache.org/docs/current/content-negotiation.html#exceptions https://httpd.apache.org/docs/2.4/mod/mod_setenvif.html#setenvif https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule So, assuming the web server filesystem has no directories matching any language code, something like this should do the job (untested): RewriteEngine on RewriteRule "^/[a-z][a-z](/.*)" "/$1" [passthrough] RewriteRule "^/[a-z][a-z]-[a-z][a-z](/.*)" "/$1" [passthrough] SetEnvIf Request_URI "^/([a-z][a-z])/" prefer-language=$1 SetEnvIf Request_URI "^/([a-z][a-z]-[a-z][a-z])/" prefer-language=$1 I'll have a look at testing this when I get time, then we can decide what method we want to use for sticky links and update the translation selection mechanism to use it. -- bye, pabs https://wiki.debian.org/PaulWise