如何mod-rewrite语言参数(如?LANG = EN)假子域(如en.mydomain.com)?参数、语言、LANG、rewrite

2023-09-02 09:45:29 作者:感情淡了,放点盐

这是很难作为一个​​菜鸟。我需要有人来帮助我做到这一点: - (

It's so hard being a noob. I need someone to help me do this :-(

因此​​,基本上,我需要用户在使用这个网址:

So basically, I need users to use this url:

连接 .mydomain.com<! - 很不错的。

en.mydomain.com <- very nice!

www.mydomain.com/index.php?lang=的连接

www.mydomain.com/index.php?lang=en

我知道这是严重的.htaccess的东西。我可能永远不会让我的头周围没有任何帮助。所以,非常感谢。

I know this is serious .htaccess stuff. Which I may never get my head around without any help. So, Thanks a lot.

推荐答案

您可以把这个规则为您的第一个规则根的.htaccess:

You can place this rule as your very first rule in root .htaccess:

RewriteEngine On

RewriteCond %{QUERY_STRING} !(^|&)lang=en(&|$) [NC]
RewriteRule ^$ /index.php?lang=en [L,QSA]