Home > CMS Tutorial > WordPress > body text

How to add domain name in wordpress

Release: 2019-07-25 09:35:13
Original
4353 people have browsed it

How to add domain name in wordpress

Webmasters who use WordPress should all know that WordPress will bind the current domain name by default when it is installed, and will bind other domain names later, but the link to the page will still be the domain name when it was installed. . So today I will share with you how to bind multiple domain names or cancel domain name binding restrictions 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']);
Copy after login

These two sentences mean to set up the website The domain name is the currently accessed domain name, which means that the binding of the domain name is cancelled. If you do not need any domain name to be accessible, but only a few domain names, you can do this:

$domain = array("www.leiue.com", "www.zhangzifan.com", "www.tearsnow.com");
if(in_array($_SERVER['HTTP_HOST'], $domain)){
    define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']);
    define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);
}
Copy after login

Put the specified domain name in the $domain array Just inside.

Note: If it is https, please change http:// in the code to https://;

If the website is installed in the secondary directory, change 'http://'. Change $_SERVER['HTTP_HOST'] to 'http://' . $_SERVER['HTTP_HOST'].'/corresponding directory name'

2. After completing the above work, your website is ready Access to multiple domain names has been achieved, but there is still a problem, that is, static resources. When pictures uploaded by WordPress are inserted into articles, the address is fixed. After changing the domain name, the domain name of the picture will not be changed, so the static file address needs to be modified. , can be solved by using the following code:

define( 'WP_CONTENT_URL', '/wp-content');
Copy after login

Just add this code below the above code.

At this point, your website has perfectly broken through the restrictions of domain name binding.

For more wordpress related technical articles, please visit the wordpress tutorial column to learn!

The above is the detailed content of How to add domain name in wordpress. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!