Change the WordPress Site URL. Thinks to do

Changing the WordPress site URL is only one part of a series of steps you need to take to ensure your WordPress site functions on the new URL.

Case #1 — Moving to a different directory
The first case is when a WordPress site moves its location into a different directory.

This could be from the primary domain to a subdirectory
aneukaceh.com to aneukaceh.com/blog

or from the subdomain to the primary domain
blog.aneukaceh.com to aneukaceh.com

If you’ve already moved your domain to a new URL, you are not able to log in since WordPress is configured to use the old URL.

Case #2 — Moving to a new domain
The last case is when a WordPress site moves from one fully hosted domain to a different one. For example:

Move from https://aneukaceh.com to https://seulanga.com

If this option applies to your site, view the following article for instructions on WordPress database at the different hosting domain

WordPress relies on the MySQL database to store its data, including site URLs. So you’ll have to make adjustments in MySQL. This article will guide you through the process, so keep reading to learn how to do it.

1. Determining the Name of WordPress MySQL Database
WordPress stores the MySQL database names and their credentials in the wp-config.php file. You can find this file in your root file directory:

  • Access your cPanel and open File Manager.
  • Open wp-config.php and search for DB_NAME. The value of this parameter is your database name. For example, the MySQL database is u123456789_wp2024.

2. Changing WordPress URLs in MySQL Database
To replace your current URL, follow these steps:

  • Go to phpMyAdmin via your website’s cPanel.
  • The left panel lists all of your databases. Select the one connected to your WordPress site and head to the SQL tab.
  • Enter the following SQL query:

    UPDATE wp_options SET option_value = replace(option_value, ‘oldurl.com’, ‘newurl.com’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;UPDATE wp_posts SET guid = replace(guid, ‘oldurl.com’,’newurl.com’);UPDATE wp_posts SET post_content = replace(post_content, ‘oldurl.com’, ‘newurl.com’); UPDATE wp_postmeta SET meta_value = replace(meta_value,’oldurl.com’,’newurl.com’);

    Replace oldurl.com with your current WordPress address and newurl.com with your new WordPress address.

  • Press Go. You will see success messages along with the number of changed rows. Note that the number of rows will be different for each WordPress website.
  • The last thing we need to do is verify the changes. Open the wp_options table and check the option_value of siteurl and home. You should see your new URL.

You may also like...