0

嗨,大家好,

我在安装多语言 WordPress 时遇到了以下问题,我想知道它是否可以通过更改 WordPress 安装而不是通过重写 Apache 网络服务器的规则来解决。

网站可以通过这种方式正确显示各种语言的内容:

捷克语内容:
http://www.example.com/cs/
http://www.example.com/cs/some-czech-page-name/
...

斯洛伐克语内容:
http://www.example.com/sk/
http://www.example.com/sk/some-slovak-page-name/
...

英语内容:
http://www.example.com/en/
http://www.example.com/en/some-english-page-name/
...

现在,是否可以修改 .htaccess 以便在各个域中显示各种语言的内容?我的意思是这样的:

捷克语内容:
http://www.example.cz/
http://www.example.cz/some-czech-page-name/
...

斯洛伐克语内容:
http://www.example.sk/
http://www.example.sk/some-slovak-page-name/
...

英语内容:
http://www.example.com/
http://www.example.com/some-english-page-name/
...
4

2 回答 2

0

尝试这个

RewriteCond %{HTTP_HOST} example.sk
RewriteCond %{REQUEST_URI} !^/sk
RewriteRule .* http://domain.com/sk/$0 [P,L]
#repeat for other domains

用于代理,P否则 WP 和 Polylang 无法解析 url。

于 2013-03-08T21:06:30.973 回答
0

这最终按预期工作。

RewriteEngine On

# EXAMPLE.COM
RewriteCond %{HTTP_HOST} www.example.com
RewriteCond %{REQUEST_URI} !^/cs/
RewriteCond %{REQUEST_URI} !^/sk/
RewriteCond %{REQUEST_URI} !^/en/
RewriteCond %{REQUEST_URI} !^/wp-admin/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /en/$1 [P,L]

# EXAMPLE.CZ
RewriteCond %{HTTP_HOST} www.example.cz
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) http://www.example.com/cs/$1 [P,L]

# EXAMPLE.SK
RewriteCond %{HTTP_HOST} www.example.sk
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) http://www.example.com/sk/$1 [P,L]

RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

但是,为了一切正常,需要进行一些模板编辑。

于 2013-03-13T07:39:38.690 回答