Wordpress implements multi domain access

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.

 Wordpress implements multi domain access

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

fabulous (0)
 Head of Mo Tao Mo Tao
Previous 9:42 am, March 17, 2020
Next 9:57 am, March 17, 2020

Related recommendations

Post reply

Your email address will not be disclosed. Required items have been used * tagging

This site uses Akismet to reduce spam comments. Learn how we handle your comment data