Mod rewrite 国际化的url重写
我正在我的网站中实现国际化,我希望用户能够输入URL,例如:Mod rewrite 国际化的url重写,mod-rewrite,url-rewriting,Mod Rewrite,Url Rewriting,我正在我的网站中实现国际化,我希望用户能够输入URL,例如: http://www.mysite.com/en/showprofile.php?id=1000 http://www.mysite.com/de/showprofile.php?id=1000 并将其改写为 http://www.mysite.com/showprofile.php?id=1000&lang=en http://www.mysite.com/showprofile.php?id=1000&lang=
http://www.mysite.com/en/showprofile.php?id=1000
http://www.mysite.com/de/showprofile.php?id=1000
并将其改写为
http://www.mysite.com/showprofile.php?id=1000&lang=en
http://www.mysite.com/showprofile.php?id=1000&lang=de
据我所知,这可以通过在我的.htaccess文件中重写url来实现。我不太确定确切的语法。提前感谢。这将是类似于:
RewriteEngine on
RewriteRule (..)/(.*)$ $2&lang=$1
理由是:将语言代码(前两个字符)作为第一个正则表达式结果,然后将URL的其余部分(直到$
)作为第二个正则表达式结果。最后,使用URL的其余部分,并附加&lang=$1
部分($1
和$2
表示括号内部分的第一个和第二个匹配项)