Sometimes there is such a need. I build my own WordPress The site hopes to be accessed through multiple domain names. We just need to modify the wp-config.php file, find the "wp-config.php" file in the root directory of the site, and then add any of the following codes as needed.
1、 Access to any domain name
Add the following code to the wp-config.php file to access any domain name, which must be placed under the sentence "define ('WP_DEBUG ', false);".
define('WP_SITEURL', 'http://' . $_ SERVER['HTTP_HOST']); define('WP_HOME', 'http://' . $_ SERVER['HTTP_HOST']);
2、 Restrict access to specific domain names
Put $domain=array ("www.domain1. com", "www.domain2. com", "www.domain3. com"); The domain name in the brackets is replaced by your own domain name, so that you can set the normal access to these domains you added. Other domain names that have not been added cannot be accessed.
$domain = array ("www.domain1.com","www.domain2.com","www.domain3.com"); if (in_array ($_SERVER ['HTTP_HOST'], $domain )) { define ('WP_SITEURL', 'http://'.$_ SERVER ['HTTP_HOST'] ); define ('WP_HOME', 'http://'.$_ SERVER ['HTTP_HOST'] ); }
Original article by Mo Tao, if reproduced, please indicate the source: https://imotao.com/1626.html