Home  >  Article  >  Backend Development  >  WordPress supports the implementation of multiple domain name binding/access

WordPress supports the implementation of multiple domain name binding/access

不言
不言Original
2018-07-09 09:45:282626browse

This article mainly introduces the implementation of WordPress supporting multiple domain name binding/access. It has a certain reference value. Now I share it with you. Friends in need can refer to it

WordPress blog program usage There are a lot of people, and there are a lot of plug-ins for optimizing and beautifying WordPress blogs. There are even articles about how to use them and how to use them online. In fact, this is why everyone likes to use WordPress to build personal blogs. Here I will share a little trick with you. By simply modifying the wp-config.php file, you can enable WordPress blogs to support binding multiple domain names and access. It is also reposted from @老江, this site is just a porter to facilitate your own search in the future, and at the same time, it is also convenient for people in need.

Before wp-config.php is not modified, the WordPress blog cannot achieve independent access to multiple domain names by default. Even if we bind multiple domain names, it will automatically jump to the default installation site when accessing. Domain name, even a domain name with www or without www will automatically jump to the default domain name. So what if we need WordPress to bind multiple domain names and have independent access? It is not difficult to bind multiple domain names to WordPress and make them accessible independently. We only 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 code according to your needs.

1. Achieve access to any domain name

Instructions: Add the following code to the wp-config.php file to achieve normal access to the blog with bound and resolved domain names without cascading. to other domain names.

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

2. Restrict access to specific domain names

It can also only refer to certain domain names that can be accessed. Pay attention to changing the domain name in the brackets of "$domain = array("www.wn789.com", "www.789wn.com", "www.wn12.cn");" to the domain name you need to bind. In this way, you can set it so that the domain names you added can be accessed normally. Other domain names that have not been added are inaccessible.

$domain = array("www.wn789.com", "www.789wn.com", " 
if(in_array($_SERVER['HTTP_HOST'], $domain)){
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']);
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);
}

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

WordPress implements the registration interface to display the password directly on the page after registration

WordPress displays articles Summary method

The above is the detailed content of WordPress supports the implementation of multiple domain name binding/access. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn