有没有办法在Wordpress中使用不同的域启用网络登录?

时间:2013-01-17 13:41:05

标签: wordpress login

我在WAMP和虚拟主机上运行了Wordpress安装。该网络有两个网站site.localsubsite.site.local,换句话说,它是子网域安装。

现在,我注意到我可以将subsite.site.local的域名更改为我喜欢的任何内容,比如anothersite.local,只要我在hosts文件和httpd.conf中配置正确,就可以了会工作,但只在前端。当我尝试登录时,Wordpress不会让我,但重定向回到登录屏幕没有信息或错误。

有什么方法吗?

1 个答案:

答案 0 :(得分:0)

在wp-config.php中使用它:

$allowed_domains = array(
   'site.local',
   'anothersite.local'
);

$cookie_domain = (in_array($_SERVER['SERVER_NAME'], $allowed_domains)) ? $_SERVER['SERVER_NAME'] : $allowed_domains[0];
define('COOKIE_DOMAIN', $cookie_domain);

它检查用户的域是否在允许的域列表中,并动态调整cookie域以匹配它。如果它不匹配,它默认为数组中的第一个域。