【发布时间】:2015-06-21 18:15:59
【问题描述】:
您好,我有一个应该提供多种语言的网站。我用wordpress做的。我想要实现的是每种语言都有自己的(虚拟)子域。例如 fr.foo.eu 和 nl.foo.eu。
目前我有以下格式的网址: foo.eu/?lang=nl foo.eu/?lang=fr
网址中可能有更多内容,例如: http://hypnose.eu/hallo-wereld/?lang=nl
我想通过以下方式使用 htaccess 获取我的网址:
http://nl.hypnose.eu/hallo-wereld/
你们能帮我实现这个目标吗?
这是我目前在 .htaccess 中的内容:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^([a-z]{2}\.hypnose\.eu$ [NC]
RewriteCond %{THE_REQUEST} \ /+([^\?]*)\?lang=([a-z]{2})&?([^\ ]*)
RewriteRule ^ http://%2.hypnose.eu/%1?%3 [L,R]
RewriteCond %{QUERY_STRING} !(^|&)lang=
RewriteCond %{HTTP_HOST} ^([a-z]{2})\.hypnose\.eu$ [NC]
RewriteRule ^(.*)$ /$1?lang=%2 [L,QSA]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
【问题讨论】:
-
您能否编辑您的问题并添加您目前拥有的
.htaccess?那太好了,所以我们可以提供一些帮助。谢谢! -
@milz 是的,我现在添加了它
标签: wordpress .htaccess mod-rewrite