Binding multiple domains to one WordPress site

如何在一个WordPress站点绑定多个域名?自己手上有好几个域名都闲置着,今天无事就折腾了一下,查了一下资料,绑定成功。

打开根目录下的 wp-config.php 文件,找到

require_once(ABSPATH . 'wp-settings.php’);

在它的前面添加以下代码:

$yovisunhome = 'http://'.$_SERVER['HTTP_HOST'];  
$yovisunsiteurl = 'http://'.$_SERVER['HTTP_HOST'];  
define('WP_HOME', $yovisunhome);   
define('WP_SITEURL', $yovisunsiteurl);

PHP中的$_SERVER[‘HTTP_HOST’] 用于获得来路域名。这样,就能根据来路为 WP_HOME 和 WP_SITEURL 变量赋值,实现 WordPress 多域名绑定。

如果网站端口非标准80端口,且wordpress不在网站根目录。可以参考以下设置:

define('WP_HOME', 'http://'.$_SERVER['HTTP_HOST'].'/ wordpress ');
define('WP_SITEURL', 'http://'.$_SERVER['HTTP_HOST'].'/ wordpress ');

其中/wordpress为wordpress所在目录。将以上两端放在本配置文档前部即可(我是放在mysql配置之前)。顺便说下,清理垃圾箱时间设置:

define('EMPTY_TRASH_DAYS', 7);

设置以后,在后台控制面板里面的“设置”->“常规”里面的“WordPress 地址(URL)”和“站点地址(URL)”选项就变为灰色,不可编辑。

912sy.com download resources are from the network, only for learning and reference use, the copyright belongs to the original author, do not use for commercial purposes, please remove yourself within 24 hours after downloading.
If the content published on this site inadvertently violates your rights and interests, please contact us and the site will be deleted within one business day.If you encounter any problems please contact customer service QQ:2385367137
912sy " Binding multiple domains to one WordPress site