[英]htaccess reposition a part of a url
您好我有一个应该有多种语言版本的网站。 我用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>
尝试添加,高于您的wordpress规则:
RewriteCond %{HTTP_HOST} !^([a-z]{2})\.foo\.eu$ [NC]
RewriteCond %{THE_REQUEST} \ /+([^\?]*)\?lang=([a-z]{2})&?([^\ ]*)
RewriteRule ^ http://%2.foo.eu/%1?%3 [L,R]
RewriteCond %{QUERY_STRING} !(^|&)lang=
RewriteCond %{HTTP_HOST} ^([a-z]{2})\.foo\.eu$ [NC]
RewriteRule ^(.*)$ /$1?lang=%1 [L,QSA]
有多语言的热门单词按插件,它为当前语言的URL设置
1)qTranslate X.
2)qTranslate
在插件中尝试预域模式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.