我在WAMP和虚拟主机上运行了Wordpress安装。该网络有两个网站site.local
和subsite.site.local
,换句话说,它是子网域安装。
现在,我注意到我可以将subsite.site.local
的域名更改为我喜欢的任何内容,比如anothersite.local
,只要我在hosts文件和httpd.conf中配置正确,就可以了会工作,但只在前端。当我尝试登录时,Wordpress不会让我,但重定向回到登录屏幕没有信息或错误。
有什么方法吗?
答案 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域以匹配它。如果它不匹配,它默认为数组中的第一个域。