Home >CMS Tutorial >WordPress >How to bind domain name in wordpress
1. Open wp-config.php in the root directory of the website and add the following content after define('WP_DEBUG', false);:
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']); define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);
These two The meaning of the sentence is to set the website domain name to the currently accessed domain name, which means canceling the binding of the domain name. If you do not need any domain name to be accessible, but only a few domain names, you can do this:
$domain = array("www.a.com", "www.b.com", "www.c.com"); if(in_array($_SERVER['HTTP_HOST'], $domain)){ define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']); define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']); }
Change the specified domain name Just put the domain name in the $domain array.
Related recommendations: "Wordpress Tutorial"
Note:
If it is https, please modify http:// in the code to https:/ /;
If the website is installed in the secondary directory, modify 'http://' . $_SERVER['HTTP_HOST'] to 'http://' . $_SERVER['HTTP_HOST'].' /Corresponding directory name'
#2. After completing the above work, your website can be accessed by multiple domain names, but there is still a problem, that is, static resources. Insert the pictures uploaded by WordPress into the article. , the address is fixed. After modifying the domain name, the domain name of the image will not be modified, so the static file address needs to be modified. This can be solved by using the following code:
define( 'WP_CONTENT_URL', '/wp-content');
Add this code below the above code .
The above is the detailed content of How to bind domain name in wordpress. For more information, please follow other related articles on the PHP Chinese website!