Three Ways to Change Domain Name in WordPress Without Modifying the Database

As we all know, to change the domain name of the WordPress website, after successfully importing the database and transferring the website database, it is necessary to modify the HOME and SITEURL addresses. Most people's practice is to modify the database, in fact, we do not have to be so troublesome and dangerous. Below, I will tell you about three ways to solve the above problems by modifying the configuration file.

Method 1: Modify wp-config.php

1. In wp-config.php, add the following two lines:

define('WP_HOME','New URL');
define('WP_SITEURL','New URL');

2. Log in to the background, and reconfigure the new blog address (HOME) and installation address (SITEURL) in "General -> Settings". After success, you must remember to delete the content added above.

Method 2: Modify functions.php

functions.php is located in the current blog theme directory, and some theme functions can be customized.

1. In functions.php, add the following two lines:

update_option('siteurl','new URL');
update_option('home','new URL');

2. Log in to the background, and reconfigure the new blog address (HOME) and installation address (SITEURL) in "General -> Settings". After success, you must remember to delete the content added above.

Method 3: Modify wp-config.php (automatically update the address)

1. In wp-config.php, add the following line:

define('RELOCATE',true);

2. Log in to the background address, WP will automatically update the installation address (SITEURL), and manually modify the blog address (HOME) address. After success, you must remember to delete the content added above.

Obviously, the third one is the easiest. There is no need to fill in the new website domain name address. The most important thing is to remember to delete the added content.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324993475&siteId=291194637