Home Website TutorialsWordPress Change WordPress website address

Change WordPress website address

by Thạch Phạm
Published: Last Updated on
A+A-
Reset

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.

chrome 6aGa97jV1r

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' );
chrome de3WoSEo2r

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' );
chrome J91QZ5cRl4

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

chrome S1URkGZIXt

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.

screenshot 2022 12 15 13.06.47@2x

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!

Đánh giá

Tham gia nhóm hỗ trợ Server - Hosting

Tham gia nhóm Hỗ trợ Server - Hosting & WordPress để cùng nhau hỏi đáp và hỗ trợ các vấn đề về WordPress, tối ưu máy chủ/server.

Tham gia ngay

Bài viết cùng chuyên mục

AZDIGI – Không chỉ là đơn vị hàng đầu trong lĩnh vực Web Hosting và Máy chủ, chúng tôi mong muốn mang lại những kiến thức bổ ích nhất và luôn cập nhật thường xuyên cho cộng đồng người đam mê thiết kế website, công nghệ,…

Vui lòng không sao chép nội dung nếu chưa xin phép. Designed and Developed by PenciDesign