How to change url in wordpress from old to new url

Hitori Tech

Changing the URL in WordPress

Changing the URL of a WordPress website can be a daunting task, but it is a necessary step when migrating your website to a new domain or subdomain. In this blog post, we will go through the steps on how to change the URL in WordPress from an old URL to a new URL, both via the WordPress Dashboard and via MySQL.

Changing the URL via the WordPress Dashboard :

The first method we will be discussing is changing the URL via the WordPress Dashboard. This method is recommended for beginners as it does not require any coding or SQL knowledge.

  1. Log in to the WordPress Dashboard of your website.
  2. Go to the Settings > General.
  3. Under the “WordPress Address (URL)” and “Site Address (URL)” sections, change the URLs to the new URL.
  4. Click on the “Save Changes” button.
URL

Changing the URL via MySQL :

The second method is changing the URL via MySQL. This method is recommended for advanced users who are familiar with SQL and have access to the database of their website.

  1. Make a backup of your database.
  2. Access the MySQL command line or use a tool like phpMyAdmin to access your WordPress database.
  3. Run the following query, replacing ‘old_url’ with your old URL and ‘new_url’ with your new URL:
UPDATE wp_options SET option_value = replace(option_value, 'old_url', 'new_url') WHERE option_name = 'home' OR option_name = 'siteurl';
  1. Run the following query, to update the URLs in the post content:
UPDATE wp_posts SET post_content = replace(post_content, 'old_url', 'new_url');
  1. Run the following query, to update the URLs in the post GUID:
UPDATE wp_posts SET guid = replace(guid, 'old_url','new_url');
  1. Run the following query, to update the URLs in the post meta:
UPDATE wp_postmeta SET meta_value = replace(meta_value,'old_url','new_url');
  1. Clear the cache of your website.
  2. Check your website to see if everything is working fine.

Conclusion :

Changing the URL of a WordPress website can be a daunting task, but it is a necessary step when migrating your website to a new domain or subdomain. In this blog post, we have covered two methods on how to change the URL in WordPress, both via the WordPress Dashboard and via MySQL.

It is important to note that both of these methods should be tested in a development environment before applying them to a live website. In addition, you should also update your permalinks, update internal links and external links to your website, and also update your Google Analytics, Google Search Console, and other webmaster tools to ensure that your website is properly indexed and tracked in search engines.

SEO Friendly Tips :

  1. Use the keyword in the title of your blog post.
  2. Use the keyword in the H1 heading of your blog post.
  3. Use the keyword in the meta description of your blog post.
  4. Use the keyword throughout the blog post in a natural way.
  5. Use internal and external linking throughout the blog post.
  6. Optimize images.

Leave a Comment