我正在编写多语言网站。我在服务器上有几个文件,例如:
/index.php
/files.php
/funny.php
并希望通过将语言代码放入 URL 来添加语言支持,如下所示:
http://mywebsite/en/index.php
将重定向到:
http://mywebsite/index.php?lang=en
和
http://mywebsite/en/files.php
将重定向到:
http://mywebsite/files.php?lang=en
我想添加更多语言,例如:
http://mywebsite/ch-ZH/index.php
而且我希望这仅适用于具有 php 和 php5 扩展名的文件。其余文件应与它们相同。
所以例如我什么时候去地址
http://mywebsite/ch-ZH/index.php
我希望我的 PHP 能够识别当前路径是
http://mywebsite
并不是
http://mywebsite/ch-ZH
这对我来说是必要的,因为在我的 PHP 代码中,我与当前路径相关,并希望它们像现在一样工作。
你能写下如何在 Apache 上准备 htaccess 文件来满足这个标准吗?