0

我在 WordPress(单个站点)上使用 Transposh 插件来拥有我的站点的英语和西班牙语版本。我想为英文版设置一个英文域名(比如 www.english.com),为西班牙文版设置一个西班牙文域名(spanish.com)。我已将 spanish.com 设置为使用带有域掩码的 english.com 转发。

我还在 wp-config.php 中添加了以下代码。

if (strpos($_SERVER['HTTP_REFERER'], 'spanish.com') !== false) :
    define('WP_SITEURL', 'http://spanish.com');
    define('WP_HOME', 'http://spanish.com');
endif;

在functions.php中:

// If coming from spanish domain, make language spanish, regardless of query string
if (strpos($_SERVER['HTTP_REFERER'], 'spanish.com') !== false) { 
    $my_transposh_plugin->target_language = 'es';
}

.ht 访问:

# This sees if the URL is from english.com and has lang=es 
# in the query string. If it does, redirect to spanish.com
RewriteCond %{QUERY_STRING} ^lang=es [NC]
RewriteCond %{HTTP_HOST} ^www\.english\.com$ [NC]
RewriteRule ^ http://spanish.com%{REQUEST_URI} [R=301,L]

唯一的问题是更改破坏了所有自动生成的文件链接。CSS/JS/IMG 链接现在转到http://spanish.com/wp-content/themes/theme/style.css。由于域掩码,该链接将转到一个 html 页面,其中 css 文件嵌入在页面的框架中。解决此问题的最佳方法是什么?

编辑:(我的编辑是错误的)

4

0 回答 0