Nội dung
There are many ways for you to change the URLs of your website with the new domain name, such as changing from help.azdigi.com to huongdan.azdigi.com, AZDIGI will detail how to do that in this article.
Step 1. Change the domain address of your WordPress website
Method 1: Change URL from WordPress admin page
Go to Settings => Overview and edit WordPress Address and Website Address as shown below with the new domain name => Save.
Method 2: Change the WordPress website URL in the functions.php file
This method is recommended when you cannot access the WordPress admin. You need to connect to the source code using a web browser or by FTP, SFTP and to the theme’s functions.php file
- Usually, the path is:domain/wp-content/themes/mytheme/functions.php
- For example, linuxcanban.com/wp-content/themes/soledad/functions.php
Then, add the 2 lines of code below to the file in the <?php tag. Don’t forget to change mydomain with your domain name.
update_option( 'siteurl', 'https://mydomain' );
update_option( 'home', 'https://mydomain' );
Method 3: Change WordPress URL in wp-config.php file
This method is only recommended when you cannot access the WordPress admin and do not know the theme you use to edit the functions.php file to update the URL.
The wp-config.php file path will mostly be in the domain/public_html/wp-config.php. You edit this file and paste the code below in the <?php tag
define( 'WP_HOME', 'https://mydomain' );
define( 'WP_SITEURL', 'https://mydomain' );
Method 4: Change WordPress URL with phpMyAdmin
This way updates the website URL directly in your database.
First, you need to determine exactly what database your website is using.
Then you access phpMyAdmin => mydatabase (the database you use) => wp-option => edit site and home url
Step 2. Replace website domain name in content
In case your website already has a lot of content, there will certainly be a lot of links using the old domain name. So you will need to do an extra step: search for the old domain name in the database and change it to the new domain name.
To do this, you can use the Better Search Replace plugin. After installing this plugin, go to WP Admin => Tools => Better Search Replace.
You enter the old domain name of the website in the Search for section and enter the new domain name in the Replace with section.
Select the entire table in the database, can use Ctrl + A
(Windows, Linux) or Cmd + A
(macOS).
Untick the Run as dry run item. Finally, press the Run Search/Replace button and wait for it to complete.
Wishing you success!