URL 重写 – 虚拟语言子文件夹
URL rewrite – virtual language subfolders
我有一个多语言网站(英语和德语),其 url 结构如下:
英文页面
http://example.com/index.php / http://example.com/index.php?lang=en_EN
http://example.com/about.php / http://example.com/about.php?lang=en_EN
http://example.com/contact.php / http://example.com/contact.php?lang=en_EN
德语页面
—
我希望这些 url 重写如下:
英文页面:
http://example.com/en/index.php, …
德语页面:
http://example.com/de/index.php, …
–
我目前拥有的是:
Options +FollowSymLinks
RewriteEngine on
RewriteRule /(.*)/(.*)\.php .php?lang=
但这根本没有任何作用……
您可以使用:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(en|de)/(.*\.php) ?lang= [NC,L]
我有一个多语言网站(英语和德语),其 url 结构如下:
英文页面
http://example.com/index.php / http://example.com/index.php?lang=en_EN
http://example.com/about.php / http://example.com/about.php?lang=en_EN
http://example.com/contact.php / http://example.com/contact.php?lang=en_EN
德语页面
—
我希望这些 url 重写如下:
英文页面:
http://example.com/en/index.php, …
德语页面:
http://example.com/de/index.php, …
–
我目前拥有的是:
Options +FollowSymLinks
RewriteEngine on
RewriteRule /(.*)/(.*)\.php .php?lang=
但这根本没有任何作用……
您可以使用:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(en|de)/(.*\.php) ?lang= [NC,L]