问题原文
原帖链接 · luneart · CC BY-SA 4.0
I want two languages on my website - one french-specific website, and one in english for broader purposes (and no automatic translation). For maintenance reasons, I'd like to not duplicate images and CSS, ... I also set up subdomains for language variants - for now both point to the www folder of my domain.
So I have two "index.htm" and "index_fr.htm" files, and a "fr" subdomain.
I've read up a bit about htaccess, and I'd like to set one up so that DirectoryIndex index_fr.htm is triggered when accessed through the subdomain.
Is it feasible? does it make sense? and how?
已采纳解答
原帖链接 · MrWhite · CC BY-SA 4.0
I don't see as you necessarily need to change the DocumentRoot of the subdomain (as discussed in comments), since you want to "share images and CSS" between language versions.
However, changing the DirectoryIndex is probably not what you want to do either.
Instead, use mod_rewrite to internally rewrite the request to /index_fr.htm when requesting the document root of the subdomain.
For example, in your root .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^fr\.example\.com [NC]
RewriteRule ^$ index_fr.htm [L]
This is essentially the equivalent of conditionally setting DirectoryIndex.
If you request https://fr.example.com/ then you'll be internally redirected to /index_fr.htm. Otherwise the normal DirectroryIndex will be served.
However, it's not clear how you want to handle requests of the form https://fr.example.com/foo? The above directive does not cover that.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
