URL重写用于多语言网页



我的实际页面结构就是这样:

https://example.com/try

将其转换为:

的最佳.htaccess规则是什么
https://example.com/fr/essayer or https://example.com/en/try

我测试的内容:

RewriteRule ^(fr|en)/(.*).php$ $2.php?lang=$1 [L,QSA]

,但我无法将页面名称更改为法语。

谢谢。

如果要使用https://example.com/fr/pageAhttps://example.com/en/pageA等URL时,在仍在使用https://example.com/fr/pageA or https://example.com/pageA的情况下,您可以使用这样的规则:

RewriteRule ^(en|fr|de)/(.+) $2 [QSA,L]

演示:http://htaccess.mwl.be?share=c26eb9b8-7d31-51-51df-9072-072-0f218032dba3

请注意,这不会通过语言代码,您可以这样做,如果需要:

RewriteRule ^(en|fr|de)/(.+) $2?lang=$1 [QSA,L]

最新更新